Mercurial > hg > ltpda
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/+utils/@math/dft.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,41 @@ +% DFT Compute discrete fourier transform at a given frequency +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DFT Compute discrete fourier transform at a given frequency +% It is defined as +% X(f) = T*sum(x(t)*exp(-1i.*2.*pi.*f.*T.*t))|t=0,...,N-1 +% where T is the sampling time +% +% CALL +% +% Gf = utils.math.dft(gt,f,T) +% +% INPUT +% +% - gt, input data series, Nx1 double +% - f, a frequency point in Hz, 1x1 double +% - T, sampling time in seconds, 1x1 double +% +% REFERENCES +% +% D. B. Percival and A. T. Walden, Spectral Analysis for Physical +% Applications (Cambridge University Press, Cambridge, 1993) p 108. +% +% L Ferraioli 09-03-2011 +% +% $Id: dft.m,v 1.2 2011/03/29 15:36:43 luigi Exp $ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +function Gf = dft(gt,f,T) + + [nn,mm] = size(gt); + if nn<mm % willing to work with columns + gt = gt.'; + end + N = numel(gt); + t = 0:N-1; + + ar = exp(-1i.*2.*pi.*f.*T.*t); + + Gf = T*(ar*gt); + + +end \ No newline at end of file