How shall I deal with frequency response function data?

It may happen that we need to start identification from frequency response function (FRF) data: magnitude (gain) and phase. The fdident toolbox is able to deal with these. Here are some pssibilities to illustrate how it works.

When the data are available as workspace variables or ASCII files or variables in MAT-files, the "Compose" command in the "Read Frequency Domain Data" block allows to easily assemble them. The fields of the Compose window can be filled in with valid MATLAB commands, like variables, subscripted variables like data(:,2), or special file references (use "Browse" at the appropriate places). When assembling the objects, the function checks the data if they are consistent indeed, and give warnings if they are not.

Especially for FRF data, please set the "Data type" menu item to the proper value. The amplitudes are either in dB-degrees vectors, or in complex form.

A special call allows the independent use of the Compose window:

     fdtool('callback','compinp','init2') %compose frequency domain objects

Command-line solution
%1. First define the data to be able to run this sequence...
%In practice, data often arrive in ASCII files. In such a case,
%load these data into MATLAB, and form vectors. Then you are done with this part.
%See 'help load' or 'help loadasc'.
%If you have the data in a Word table, do the following:
%  Select the table
%  Through the menu, Table / Convert / Table to text
%      Select the separator as Tab mark
%  Delete everything else than the data (the numbers) themselves
%  Save it as a txt file
%  Execute in Matlab
%      load data.txt -ascii
%      Now you have an array which corresponds to the table
%The following 3 lines are just preparations for simulation, not needed for true data
F=20; freqv=[1:F]'/F*1e3; %frequency vector (NOT radian frequencies), 1/20 kHz steps 
jomega=j*2*pi*freqv; K=2e-4; %Time constant in seconds
tf=1./(1+jomega*K); %Complex amplitudes, 1st order system
%Here are a few examples how to deal with the vectors:
tf_mag=abs(tf); %Magnitude vector
%tf_mag_dB=20*log10(tf_mag); %This would be the magnitude in decibels
tf_phase=angle(tf); %Phase, radians
%tf_phase_degrees=tf_phase/(2*pi)*360; %this would be the phase in degrees
U=ones(size(tf_mag)); %the input amplitudes are all equal to one with zero phase
Y=tf_mag.*exp(j*tf_phase); %Complex output Fourier amplitudes
%or, starting from dB-degrees data:
%2. Now form an object from the data. We will use here freqv, Y, and U.
%If you have several repeated experiments:
%If you have variance data of the Fourier amplitudes (scalars or vectors):
%dat.variance=[varY,varU]; %variance column vectors, to prepare the fit
%if the variances are not known, you may leave the variances empty
%Remark: advanced users may also use the coherence data instead, to obtain 
%approximate variances, assuming that small coherence is caused by noise alone.
%If these are in the vector 'cohvect',
%  vartf=coh2var(cohvect,Y./U);
%  dat.variance=[vartf,zeros(size(U))];
%Warning! Make sure that no measured coherence is over 1 (this might happen
%in some instruments because of roundoff errors).
%3. Make an estimation
figure(3), plot(model)

Alternatively, a quick way when you already have an fiddata object dat,

Back to the fdident FAQ page     Back to the Developers' Page