How to implement FFT in Matlab?
Y = fft( X , n ) returns the n -point DFT. If no value is specified, Y is the same size as X . If X is a vector and the length of X is less than n , then X is padded with trailing zeros to length n . If X is a vector and the length of X is greater than n , then X is truncated to length n .
How to plot magnitude of FFT in Matlab?
y = fft(x); fs = 1/Ts; f = (0:length(y)-1)*fs/length(y); When you plot the magnitude of the signal as a function of frequency, the spikes in magnitude correspond to the signal's frequency components of 15 Hz and 20 Hz.