Main Content

Estimate Frequency Response at the Command Line

This example shows how to estimate the frequency response of a Simulink® model at the MATLAB® command line.

Open the Simulink model.

mdl ='scdplane'; open_system(mdl)

For more information on the general model requirements for frequency response estimation, seeModel Requirements.

Specify input and output points for frequency response estimation using analysis points. Avoid placing analysis points on bus signals.

io(1) = linio('scdplane/Sum1',1); io(2) = linio('scdplane/Gain5',1,'output');

For more information about linear analysis points, seeSpecify Portion of Model to Linearizeandlinio.

Linearize the model and create a sinestream signal based on the dynamics of the resulting linear system. For more information, seeEstimation Input Signalsandfrest.Sinestream.

sys = linearize('scdplane',io); input = frest.Sinestream(sys);

If your model has not reached steady state, initialize the model using a steady-state operating point before estimating the frequency response. You can check whether your model is at steady state by simulating the model. For more information on finding steady-state operating points, seeCompute Steady-State Operating Points.

Find all source blocks in the signal paths of the linearization outputs that generate time-varying signals. Such time-varying signals can interfere with the signal at the linearization output points and produce inaccurate estimation results.

srcblks = frest.findSources('scdplane',io);

To disable the time-varying source blocks, create anfrestimateOptionsoption set and specify theBlocksToHoldConstantoption.

opts = frestimateOptions; opts.BlocksToHoldConstant = srcblks;

Estimate the frequency response.

[sysest,simout] = frestimate('scdplane',io,input,opts);

sysestis the estimated frequency response.simoutis aSimulink.Timeseriesobject representing the simulated output.

To speed up your estimation or decrease its memory requirements, seeManaging Estimation Speed and Memory.

Open the Simulation Results Viewer to analyze the estimated frequency response.

frest.simView(simout,input,sysest)

你也可以比较估计频率uency response,sysest, to an exact linearization of your system,sys.

frest.simView(simout,input,sysest,sys)

TheBode Diagramplot shows the responsesysas a blue line.

See Also

|||||

Related Topics