Identify time-varying source blocks
Time-varying source blocks in a Simulink® model can interfere with frequency response estimation by driving the model away
from the operating point of the linearized system. Using the
frest.findSources function, you can identify such time-varying sources
in your model. You can then disable the identified sources before estimating a frequency
frestimate. For more information, see Effects of Time-Varying Source Blocks on Frequency Response Estimation.
Disable Time-Varying Source Blocks for Frequency Response Estimation
Open a model that contains time-varying source blocks.
mdl = "scdspeed_ctrlloop"; open_system(mdl)
Set the engine reference model to normal simulation mode for accurate linearization.
set_param("scdspeed_ctrlloop/Engine Model",... "SimulationMode","Normal")
Obtain the linear analysis points that are defined in the model.
io = getlinio(mdl);
Estimate the frequency response of the model without disabling the time-varying source blocks. Define a sinestream input signal and obtain the estimated frequency response
in = frest.Sinestream(... "Frequency",logspace(1,2,10),... "NumPeriods",30,... "SettlingPeriods",25); [sysest,simout] = frestimate(mdl,io,in);
To view the impact of the time-varying sources on the estimation result, compute an exact linearization of the model and compare it to the estimated response.
sys = linearize(mdl,io); bodemag(sys,sysest,'r*')
The estimated frequency response does not match the exact linearization. The mismatch occurs because time-varying source blocks in the model prevent the response from reaching steady state.
Find the time-varying source blocks.
srcblks = frest.findSources(mdl);
To disable the source blocks, first create an
frestimateOptions object and set the
BlocksToHoldConstant parameter to the time-varying source blocks.
opts = frestimateOptions("BlocksToHoldConstant",srcblks);
Estimate the frequency response with the time-varying source blocks disabled.
[sysest2,simout2] = frestimate(mdl,io,in,opts);
Compare the estimated response
sysest2 with the exact linearization result.
The estimated response matches the exact linearization.
model — Name of model
string | character vector
Name of the Simulink model for which you want to identify time-varying sources.
io — Linear analysis points
linearization I/O object | array of linearization I/O objects
Linear analysis points representing inputs, outputs, and loop openings, specified as
a linearization I/O object or an array of such objects. The
frest.findSources function uses only the linearization output
For more information on specifying linear analysis points, see Specify Portion of Model to Linearize and Specify Portion of Model to Linearize at Command Line.
blocks — Time-varying source blocks
Time-varying source blocks, returned as a array of
blocks includes time-varying source blocks inside
subsystems and normal-mode referenced models.
If you specify
blocks contains all
time-varying source blocks contributing to the signal at the output analysis points in
If you do not specify
all time-varying source blocks contributing to the signals at the output analysis points
model. For more information on specifying analysis points
in your model, see Specify Portion of Model to Linearize in Simulink Model.
To disable time-varying source blocks during frequency response estimation, first create an
frestimateOptionsobject and set its
blocksor a subset of
blocks. Then, estimate the frequency response using
modelincludes a reference model that contains a source block in the signal path of a linearization output point, set the reference model to normal simulation mode before finding sources using
You can use the Simulink Model Advisor to determine whether time-varying source blocks exist in the signal path of output linear analysis points in your model. To do so, use the Model Advisor check Simulink Control Design Checks. For more information about using the Model Advisor, see Check Your Model Using the Model Advisor.
You can find and disable time-varying sources in your model when estimating frequency responses in the Model Linearizer app.
Introduced in R2010b