Identify time-varying source blocks
blocks = frest.findSources(model)
blocks = frest.findSources(model,io)
Character vector or string that contains the name of the Simulink model in which you are identifying time-varying source blocks for frequency response estimation.
Array of linearization I/O points.
The elements of
Block paths of time-varying source blocks in
If you provide
If you do not provide
Estimate the frequency response of a model having time-varying
source blocks. This example shows the use of
identify time-varying source blocks that interfere with frequency
response estimation. You can also see the use of
frestimateOptions to disable time-varying
source blocks in the estimation.
Load the model
mdl = 'scdspeed_ctrlloop'; open_system(mdl) % Convert referenced model to normal mode for accuracy set_param('scdspeed_ctrlloop/Engine Model',... 'SimulationMode','Normal');
First, view the effects of time-varying source blocks on frequency response estimation. To do so, perform the estimation without disabling time-varying source blocks.
In this example, linearization I/O points are already defined
in the model. Use the
getlinio command to get
the I/O points for
io = getlinio(mdl)
Define a sinestream signal and compute the estimated frequency
in = frest.Sinestream('Frequency',logspace(1,2,10),... 'NumPeriods',30,'SettlingPeriods',25); [sysest,simout] = frestimate(mdl,io,in);
Perform exact linearization, and compare 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 blocks using
srcblks = frest.findSources(mdl);
srcblks is an array of block paths corresponding
to the time-varying source blocks in the model. To examine the result,
index into the array.
For example, entering
returns the result
ans = Simulink.BlockPath Package: Simulink Block Path: 'scdspeed_ctrlloop/Engine Model' 'scdspeed_plantref/Drag Torque/Step1'
Now you can estimate the frequency response without the contribution
of the time-varying source blocks. To do so, set the
frestimateOptions equal to
and run the estimation.
opts = frestimateOptions opts.BlocksToHoldConstant = srcblks % Run frestimate again with blocks disabled [sysest2,simout2] = frestimate(mdl,io,in,opts);
The frequency response estimate now provides a good match to the exact linearization result.
frest.findSourcesto identify time-varying source blocks that can interfere with frequency response estimation. To disable such blocks to estimate frequency response, set the
blocksor a subset of
blocks. Then, estimate the frequency response using
modelincludes referenced models containing source blocks in the signal path of a linearization output point. In such cases, set the referenced models to normal simulation mode to ensure that
frest.findSourceslocates them. Use the
set_paramcommand to set
SimulationModeof any referenced models to
To locate time-varying source blocks that can interfere with
frequency response estimation,
at each linearization output point in the model. From each output
point, the algorithm traces every signal path backward block by block.
The algorithm reports any source block (a block with no input port)
it discovers, unless that source block is a Constant or Ground block.
frest.findSources algorithm traces every signal path that can affect
the signal value at each linearization output point in the model. The paths traced
Signal paths inside virtual and nonvirtual subsystems.
Signal paths inside normal-mode referenced models. Set all referenced models to normal simulation mode before using
frest.findSourcesto ensure that the algorithm identifies source blocks within the referenced models.
Signals routed through switches. The
frest.findSourcesalgorithm assumes that any pole of a switch can be active during frequency response estimation. The algorithm therefore follows the signal back through all switch inputs.
Some time-varying source blocks might not be found by
frest.findSources. If the internal signal path of a block does not
contain a block with no input port, that block is not reported by the function.
For example, consider the model
This model has one linearization output point, located at the output
of the Sum block labeled
frest.findSources algorithm ignores linearization
input points.) Before running
convert the referenced model to normal simulation mode:
set_param('scdspeed_ctrlloop/Engine Model',... 'SimulationMode','Normal');
You can now run
frest.findSources to identify
the time-varying source blocks using the linearization output point
defined in the model.
srcblks = frest.findSources('scdspeed_ctrlloop');
The algorithm begins at the output point and traces back through
the Sum block
Speed Output. One
Speed Output is the subsystem
Disturbance. The algorithm enters the subsystem, finds the
source block labeled
Step Disturbance, and reports
The Sum block
Speed Output has
another input, which the algorithm traces back into the referenced
Engine Model contains
several subsystems, and the algorithm traces the signal through these
subsystems to identify any time-varying source blocks present.
For example, the
Combustion subsystem includes
the From block marked
routes the signal from the
Spark Advance source.
Spark Advance is a constant source block,
however, the algorithm does not report the presence of the block.
The algorithm continues the trace until all possible signal paths contributing to the signal at each linearization output point are examined.
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.