Mercurial > hg > ltpda
diff m-toolbox/classes/+utils/@math/getfftfreq.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/+utils/@math/getfftfreq.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,22 @@ +% +% GETFFTFREQ: get frequencies for fft +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Luigi Ferraioli 04-02-2011 +% +% % $Id: getfftfreq.m,v 1.1 2011/02/04 11:11:29 luigi Exp $ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +function f = getfftfreq(nfft,fs,type) + switch lower(type) + case 'plain' + f = (0:nfft-1).*fs./nfft; + case 'one' + f = (0:floor(nfft/2)).*fs./nfft; + case 'two' + if rem(nfft,2) % odd number of data + f = fftshift([0:floor(nfft/2) -(floor(nfft/2)):-1].*fs./nfft); + else % even number of data + f = fftshift([0:floor(nfft/2)-1 -floor(nfft/2):-1].*fs./nfft); + end + end +end \ No newline at end of file