There are many functions in the Matlab identification toolbox. Here is a simple example to show how to use the estimated system transfer function.
For example, our task is to know the input and output of the system, but the system is unknown. It is a black box, and we need to estimate the transfer characteristics of the system .
Our system input and output data are as follows
The system is unknown, we solve for the system response by estimating the power spectrum
Transfer function estimate - MATLAB tfestimate
The system frequency response is obtained by dividing the cross-power spectrum and the self-power spectrum
[pxx,f1] = pwelch(x,window,noverlpap,Nfft,fs);
[pyx ,f2]= cpsd(y,x,window,noverlpap,Nfft,fs);
tfunc=pyx./pxx;
We get the system frequency response (magnitude and phase)
plot(f,(abs(tfunc)));
title('Transmission tf amplitude small range');
xlim([0,20]);
plot(f,(angle(tfunc)));
title('Transmission tf phase small range');
xlim([0,20]);
ypf = angle(tfunc);
That 's exactly the same frequency response as we're using
The transfer function of the system is estimated as follows
Create Frequency Response Object
creates a discrete-time sysfr
= idfrd(ResponseData,Frequency,Ts)idfrd
object that stores the frequency response ResponseData of a linear system at frequency values Frequency. Ts is the sample time. For a continuous-time system, set Ts
to 0
.
sys = arx(data,[na nb nk])
estimates the parameters of an ARX or an AR idpoly model sys
using a least-squares method and the polynomial orders specified in [na nb nk]
. The model properties include covariances (parameter uncertainties) and goodness of fit between the estimated and measured data.
The above na nb nk are respectively, the number of denominator coefficients, the number of numerator coefficients and delay
Unfortunately, we don't know the number of poles and zeros of this unknown system (or the order of the polynomial)
ypf = abs(tfunc);
xpf = f;
frdobj = idfrd(ypf,xpf,1/fs);
modelobj = arx(frdobj,[4 3 0])
modeltf = tf(modelobj);
b = cell2mat(get(modeltf,'Numerator'));
a = cell2mat(get(modeltf,'Denominator'));
Estimated system response, the characteristics of the two peaks have been simulated
unit shock
step(modeltf)
Transfer Function
pole-zero form
zplane pole-zero plot