comparison m-toolbox/classes/+utils/@math/dft.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 % DFT Compute discrete fourier transform at a given frequency
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % DFT Compute discrete fourier transform at a given frequency
4 % It is defined as
5 % X(f) = T*sum(x(t)*exp(-1i.*2.*pi.*f.*T.*t))|t=0,...,N-1
6 % where T is the sampling time
7 %
8 % CALL
9 %
10 % Gf = utils.math.dft(gt,f,T)
11 %
12 % INPUT
13 %
14 % - gt, input data series, Nx1 double
15 % - f, a frequency point in Hz, 1x1 double
16 % - T, sampling time in seconds, 1x1 double
17 %
18 % REFERENCES
19 %
20 % D. B. Percival and A. T. Walden, Spectral Analysis for Physical
21 % Applications (Cambridge University Press, Cambridge, 1993) p 108.
22 %
23 % L Ferraioli 09-03-2011
24 %
25 % $Id: dft.m,v 1.2 2011/03/29 15:36:43 luigi Exp $
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 function Gf = dft(gt,f,T)
28
29 [nn,mm] = size(gt);
30 if nn<mm % willing to work with columns
31 gt = gt.';
32 end
33 N = numel(gt);
34 t = 0:N-1;
35
36 ar = exp(-1i.*2.*pi.*f.*T.*t);
37
38 Gf = T*(ar*gt);
39
40
41 end