Convert time domain data to frequency domain data for elis.
Syntax
[x,y] = tim2fou(tdat,freqv)
[x,y,fv] = tim2fou(tdat,freqv,expi)
Description
The time domain data vector is given in tdat (see exptim); or this is an array [tvl,xt,yt], where the column vector tvl contains the time instants, repeated with the same values for each experiment; or this is the name of the time domain data file, with obligatory extension .tbn, .tim, or .tnt.
tdat can also be the name of an M-file. For example, if tdat = 'gettim', the call [tv,xt,yt] = gettim(i) must return the results of experiment i for the values contained in expi.
freqv is the desired frequency vector; possibly each element of freqv should be a divider of the sampling frequency, but the algorithm works even if this is not true. If freqv is empty or missing, all possible frequencies in the FFT grid will be used from 0 to fs/2.
The generated input and output vectors (or arrays for multiple inputs or outputs) of complex amplitudes are x and y. Multiple experiments can also be processed. The actually used frequency vector is returned in fv.
Default Argument Values
freqv = [0:N/2-1]'/N*fs, where N is the length of the time vectors, and fs = 1/dt is the sampling frequency.
Examples
[x,y,fv] = tim2fou([[0:63]',cos([0:63]'/64*2*pi*3)]);
Diagnostics
The time vector should consist of equidistant points, otherwise an error message is sent:
Samples are not equidistant
fs = 1/dt should be larger than the maximum of freqv, otherwise an error message is generated:
Maximum of freqv is larger than fs/2
Every element of freqv has to be a divider of the sampling frequency, otherwise a warning message is sent:
'WARNING: frequencies are not FFT points, leakage will appear
Algorithm
The usual expression of the DFT is evaluated:
If the frequency points in freqv are on the FFT grid, the DFT of the time domain vectors is calculated via FFT, and the corresponding complex amplitudes are selected. Otherwise the DFT is evaluated for the given frequency points.
See Also
exptim
[ Previous | Help Desk | Next ]