comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 %
2 % GETFFTFREQ: get frequencies for fft
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 %
5 % Luigi Ferraioli 04-02-2011
6 %
7 % % $Id: getfftfreq.m,v 1.1 2011/02/04 11:11:29 luigi Exp $
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9 function f = getfftfreq(nfft,fs,type)
10 switch lower(type)
11 case 'plain'
12 f = (0:nfft-1).*fs./nfft;
13 case 'one'
14 f = (0:floor(nfft/2)).*fs./nfft;
15 case 'two'
16 if rem(nfft,2) % odd number of data
17 f = fftshift([0:floor(nfft/2) -(floor(nfft/2)):-1].*fs./nfft);
18 else % even number of data
19 f = fftshift([0:floor(nfft/2)-1 -floor(nfft/2):-1].*fs./nfft);
20 end
21 end
22 end