from
One-Sided FFT
by Aravazhi Anbarasu
More intuitive than built in function for simple operations.Useful for repetitive code and plotiing.
|
| fft_calc(X,fs)
|
%%FFT
%%Ara Anbarasu
%Input |%Output
%fs = Sample frequency of data |%y = OneSided fft
%X = Data set |%f = Frequency range
function [f y] = fft_calc(X,fs)
l=length(X);%Length and breadth of the data signal
NFFT = 2^nextpow2(l); % Next power of 2 from length of y
Y = fft(X,NFFT)/l;%compute fft
f = [0 : NFFT/2]'/NFFT*fs;
y = 2*abs(Y(1:NFFT/2+1));
clear -regexp ^r\d{1}$;
clear time;
end
|
|
Contact us