Wrapper for the fft function. Inputs: y - sampled data fs - sample frequency in Hz Outputs: f - frequency vector of the fft spectrum [units of Hz] Y - fftshift(fft(y)) ogk
0001 function [f,Y] = ffto(y,fs) 0002 % Wrapper for the fft function. 0003 % Inputs: 0004 % y - sampled data 0005 % fs - sample frequency in Hz 0006 % Outputs: 0007 % f - frequency vector of the fft spectrum [units of Hz] 0008 % Y - fftshift(fft(y)) 0009 % 0010 % ogk 0011 0012 Y = fftshift(fft(y),1); 0013 f = [-length(Y)/2:length(Y)/2-1]*fs/length(Y); 0014 f = f(:); 0015 % Alternative calculation: 0016 % F = [0:length(Y)-1]*fs/length(Y); 0017 % f = [-fliplr(F(2:length(F)/2+1)) F(1:length(F)/2)]; 0018 0019 end