Mu Analysis and Synthesis Toolbox | ![]() ![]() |
Calculate FFTs, inverse FFTs, and perform spectral analysis on VARYING matrices
Syntax
yfreq = vfft(ytime,n) ytime = vifft(yfreq) P = vspect(x,m,noverlap,'window') P = vspect(x,y,m,noverlap,'window')
Description
vfft
implements the MATLAB fft command on VARYING matrix structures. A one-dimensional FFT of length n
is performed on each element of the VARYING matrix ytime
. It is assumed that the independent variable is in units of seconds. The independent variables are regularly spaced -- only the first interval is used to determine the frequency scale. yfreq
is returned with the independent variable, frequency, in radians/second.
vifft
performs the inverse FFT. This is done with the MATLAB command ifft(yfreq)
for each element of the VARYING matrix.
vspect
is the VARYING matrix structure equivalent of the Signal Processing Toolbox command, spectrum. For algorithmic details, see the spectrum command. Note that vspect
gives you the option of specifying a window for the data. For example, using the string hamming
as the fifth argument generates a window with the command window = hamming(n);
. hamming
is an M-file in the Signal Processing Toolbox. You can use custom windows by specifying the name as the window
argument.
In the case of the spectrum of a single signal, the command
will return a VARYING matrix,P
, containing the power spectral density of x
. Note that x
, and therefore P
, can be a matrix of signals. In the case of the spectrum, and cross-spectrum, of two signals, the command
P = vspect
(x,y,m
,noverlap,'window');
will return a VARYING matrix, P
, with the following five columns.
Pxx |
Power spectral density of x |
Pyy |
Power spectral density of y |
Pxy |
Cross spectral density |
Txy |
Complex transfer function between x and y |
Cxy |
Coherence function between x and y |
The signal x, must be scalar (i.e., a one row, one column, VARYING matrix). y
can be a vector signal. The row dimension of p
is the same as that of y
. vspect
can do single-input, multiple-output (SIMO) identification. This is illustrated in the following example. Refer also to the example in the Tutorial chapter.
vfft
, vifft
, and vspect
have not been optimized for speed. The appropriate row and column data is extracted from the VARYING matrices with the µ-Tools commands, sel
and xtract
. sbs
and abv
are used to create the final output.
Examples
A single-input two-output system is generated as an identification example. This example is only a simple illustration of some of the frequency domain techniques available.
a1 = [-.1,1;-1,-0.05]; b1 = [1;1]; c1 = [-0.5,0]; sys1 = pck(a1,b1,c1); a2 = [-.1,0.5;-0.5,-0.1]; b2 = [1;1]; c2 = [-0.5,0]; sys2 = pck(a2,b2,c2); sys = abv(sys1,sys2); minfo(sys) system:4 states2 outputs1 inputs
u
is the input to the system. siggen
is used to generate some random noise on the output signal, y
.
y = madd(trsp(sys,u),siggen('[0.01*rand(size(t));0.025*rand(size(t)) ]',t)); integration step size: 0.05 vplot(y) title('vspect example: output waveform with noise') xlabel('time: seconds')
vspect
command specifies a 1024 point window, with 512 points of overlap. A Hamming window is applied to the data.
Column 4 in P
contains the complex transfer function estimate. Its magnitude is compared to the actual system transfer function.
omega = logspace(-2,2,100); omega2 =[ [0.05:0.1:1.5] [1.6:.5:20] [0.9:0.01:1.1] ]; omega = sort([omega omega2]); sys_g = frsp(sys,omega); vplot('liv,lm',sel(P,1:2,4),sys_g); Warning: Data includes a number that is negative or zero. The LOG of this results in NaN or Infinity and is not shown on plot. title('vspect example: transfer function estimation ') ylabel('magnitude') xlabel('frequency: rad/sec')
Algorithm
vfft
, vifft
, and vspectrum
call the MATLAB commands fft
and ifft
.
Reference
Ljung, L., System Identification: Theory for the User, Prentice Hall, New Jersey, 1987.
Oppenheim, A.V., and R.W. Schafer, Digital Signal Processing, Prentice Hall, New Jersey, 1975.
![]() | veval | vfind | ![]() |