MATLAB: Using an iddata object, how to plot multiple frequency response estimations in the same bode plot, using Hz for the x-axis units

controlsdesignfreqidentificationstablesysidsystemSystem Identification Toolboxunstable

Using an iddata object, how do I plot multiple frequency response estimations in the same bode plot, using Hz for the x-axis units?

Best Answer

After estimating the frequency response of your data, you can use the "bodeplot" function and set the options to use Hz for the x-axis units.
Check out this template to create an iddata object, estimate the frequency response with several types of estimators, and then plot the results in the same bode plot.
DataObj=iddata(YourOutputDataVector,YourInpuDataVector,YourDataSampleTime);
% non-parametric
G1=spafdr(DataObj);
G2=spafdr(DataObj,'max',logspace(-1,2,100));
% parametric
zf = fft(DataObj);
mf=tfest(zf,4,4);
b = bodeplot(G1,G2, mf,G1.freq);
setoptions(b,'FreqUnits','Hz');