Frequency response estimation of Simulink models
[___] = frestimate(___,
computes the frequency response using additional options. You can use this syntax with any
of the previous input and output argument combinations.
Estimate Frequency Response of a Portion of a Simulink Model
Estimate the open-loop response of the plant in the
watertank model. Open the model.
model = 'watertank'; open_system(model)
To estimate the open-loop response of the plant, define a linearization I/O set that specifies this portion of the model with analysis points. Define an input analysis point at the controller output, and define an open-loop output point at the plant output.
io(1)=linio('watertank/PID Controller',1,'input'); io(2)=linio('watertank/Water-Tank System',1,'openoutput');
Find a steady-state operating point for the estimation. For this example, use a steady-state operating point derived from the model initial conditions.
watertank_spec = operspec(model); opOpts = findopOptions('DisplayReport','off'); op = findop(model,watertank_spec,opOpts);
Create an input signal for estimation. For this example, use a sinestream signal, which sends a series of separate sinusoidal perturbations at the frequencies you specify.
input = frest.Sinestream('Frequency',logspace(-3,2,30));
Estimate the frequency response of the specified portion of the model. The result is a frequency-response model containing responses at each of the frequencies specified in the sinestream signal.
sysest = frestimate(model,op,io,input); size(sysest)
FRD model with 1 outputs, 1 inputs, and 30 frequency points.
Examine the measured frequency response.
Validate Exact Linearization Results Using Estimated Frequency Response
Linearize a Simulink model and use frequency-response estimation to validate the exact linearization results.
model = 'watertank'; open_system(model);
Obtain a linearization of the open-loop response of the plant. To do so, define the linearization I/O points, and find a steady-state operating point near the model initial conditions. Then, linearize the model.
io(1)=linio('watertank/PID Controller',1,'input'); io(2)=linio('watertank/Water-Tank System',1,'openoutput'); watertank_spec = operspec(model); opOpts = findopOptions('DisplayReport','off'); op = findop(model,watertank_spec,opOpts); syslin = linearize(model,op,io);
To check the linearization, use the same analysis points and operating point to estimate the frequency response. For this example, use a sinestream input signal for the estimation.
input = frest.Sinestream('Frequency',logspace(-3,2,20)); sysest = frestimate(model,op,io,input);
Compare the exact linearization and the estimated response in the frequency domain using a Bode plot.
bode(syslin,'b-',sysest,'r*') legend('Exact linearization','Estimation')
Examine Estimation Results Using Simulation Results Viewer
The Simulation Results Viewer lets you examine the results of frequency response estimation frequency by frequency. You open the viewer using the
frest.simView command. To do so, store the simulation data using the
simout output argument of
Estimate the open-loop response of the plant in the
watertank model. First, open the model.
model = 'watertank'; open_system(model)
Define a linearization I/O set that specifies the plant, and find a steady-state operating point for estimation.
io(1)=linio('watertank/PID Controller',1,'input'); io(2)=linio('watertank/Water-Tank System',1,'openoutput'); watertank_spec = operspec(model); opOpts = findopOptions('DisplayReport','off'); op = findop(model,watertank_spec,opOpts);
Then, create an input signal for estimation, and estimate the frequency response of the specified portion of the model. Use the
simout output argument to store the estimation data.
input = frest.Sinestream('Frequency',logspace(-3,2,10)); [sysest,simout] = frestimate(model,op,io,input);
Open the Simulation Results Viewer.
The viewer shows you the steady-state time response and the FFT of that response for all frequencies within the range you select on the Bode Diagram section of the viewer. These plots can help you identify when the response deviates from the expected response. For more information about using the Simulation Results Viewer, see Analyze Estimated Frequency Response.
If you have a linear model of the system you are estimating, you can use the model as a baseline response for comparison in the viewer. For instance, you can compare a model obtained by exact linearization to the estimated frequency response. Use the linearization I/O set and the operating point to compute an exact linearization of the
syslin = linearize(model,io,op);
Open the Simulation Results Viewer again, this time providing
syslin as an input argument.
The Bode Diagram section of the viewer includes a line showing the exact response
syslin. This view can be useful to identify particular frequencies where the estimated response deviates from the linearization.
model — Simulink model
string | character vector
Simulink model, specified as a string or character vector. The model must be in the current working folder or on the MATLAB® path.
io — Analysis points set
linearization I/O object
Analysis points set that contain inputs, outputs, and loop openings, specified as a
linearization I/O object. The analysis point set defines the subset of the Simulink model whose frequency response you want to estimate. To create
For frequency response estimation, I/O points cannot be on bus signals.
io must correspond to the Simulink model
model or a normal mode model reference in the
model hierarchy. (If you use
frestimate with an output analysis
point in a model reference, the Total number of instances allowed per top
model configuration parameter of the referenced model must be 1.)
Specifying I/O points for estimation is similar to specifying them for linearization. For more information on specifying linearization inputs, outputs, and openings, see Specify Portion of Model to Linearize.
input — Input signal
sinestream signal | chirp signal | random signal | time series
Input signal for perturbing the model, specified as one of the following:
For more information about creating input signals for frequency response estimation, see Estimation Input Signals.
op — Operating point
Operating point at which to initialize the model for estimation, specified as an
OperatingPoint object created using one of the following
Generally, you use a steady-state operating point for estimation. If you do not specify an operating point, the estimation process begins at the operating point specified by the model initial conditions. This operating point consists of the initial state and input signal values stored in the model.
options — Estimation options
Estimation options, specified as a
frestimateOptions object. Available options include enabling parallel
computing for estimation (requires Parallel Computing Toolbox™).
data — Response data logged for offline estimation
Response data logged for offline estimation using the Frequency Response Estimator block, specified as one of the following:
A structure obtained by writing the data from the data output port of the block to the MATLAB workspace using a To Workspace block. The Save format parameter of the To Workspace block must be
Simulink.SimulationData.Datasetobject obtained by using Simulink data logging to write the data at the data port to the MATLAB workspace.
For more information, see the data port description on the Frequency Response Estimator block reference page or Collect Frequency Response Experiment Data for Offline Estimation.
freqs — Frequencies for offline estimation
Frequencies for offline estimation, specified as a vector of positive values. When
you collect response data using the Frequency Response Estimator block,
you specify the frequencies for the estimation experiment using the
Frequencies parameter of the block. Use the same vector of
freqs when you perform offline estimation with the
units — Units
Units of frequencies for offline estimation, specified as one of the strings
"Hz" or one of the character vectors
'Hz'. When you collect response data
using the Frequency Response Estimator block, you specify the units of
the frequencies for the estimation experiment using the frequency units block parameter.
Specify the same units when you perform offline estimation with the logged data.
sysest — Estimated frequency response
The frequencies in
sysest depend on what input signal you use
for estimation, as follows:
If you use a sinestream signal created with
frest.Sinestream, the frequencies in
sysestare the frequencies specified in the sinestream signal.
If you use any other input signal, the frequencies are determined by the FFT computation that the function performs to extract the frequency response (see Algorithms).
If you use the
data input argument to provide data collected
using the Frequency Response Estimator block, then
sysest is a SISO model. In this case, the frequencies in
sysest are the frequencies you supply with the
freqs input argument.
simout — Simulation data
cell array of
Simulation data collected during the estimation process, returned as a cell array of
Simulink.Timeseries objects. The cell array has
the number of output points in the I/O set
n is the number of input points. This data can be useful for:
Examining estimation results using
frest.simView(see Examine Estimation Results Using Simulation Results Viewer)
Examining time-domain responses using
If you use
frestimatewith an output analysis point in a model reference, the Total number of instances allowed per top model configuration parameter of the referenced model must be 1.
For multiple-input multiple-output (MIMO) systems,
frestimateinjects the signal at each input channel separately to simulate the corresponding output signals. The estimation algorithm uses the inputs and the simulated outputs to compute the MIMO frequency response. If you want to inject different input signals at the linearization input points of a multiple-input system, treat your system as separate single-input systems. Perform independent frequency response estimations for each linearization input point using
frestimate, and concatenate your frequency response results.
frestimate injects the input signal you specify (uest(t)) at the input analysis points. It simulates the model and collects the
response signal (yest(t)) at the output analysis points, as illustrated below for a sinestream
frestimate estimates the frequency response by computing
the ratio of the fast Fourier transforms output signal and the input signal:
For sinestream input signals, the function discards the data collected during the specified settling periods of the signal at each frequency. (See Sinestream Input Signals.) If the filtering option of the sinestream signal is active, the function then applies a bandpass filter to the remaining signal at the corresponding frequency and discards one more period to remove any remaining transient signals. The function uses the FFT of the resulting signal to compute Resp. The resulting
frdmodel contains all frequencies in the sinestream.
For chirp input signals, the function discards any frequencies in the ratio Resp that fall outside the frequency range specified for the chirp. The resulting
frdmodel contains all frequencies in the Fourier transform that fall within the chirp range.
For other input signals, the resulting
frdcontains all the frequencies in the Fourier transform.
Estimation Using Data from Frequency Response Estimator Block
You can use the
syntax to perform offline estimation with data from the Frequency Response
Estimator block. In this case,
frestimate uses the
Ready field of the data structure to determine which data points to
include the FFT computation of Resp.
For sinestream mode, this signal indicates which periods to discard at each frequency, determined by the Number of settling periods block parameter.
For superposition mode, this signal indicates which data falls within the data-collection window determined by the Number of periods of the lowest frequency used for estimation parameter.
frestimate interpolates Resp to generate the
frd model, which contains the frequencies you specified in
the block experiment parameters. For more information, see the Frequency Response
Estimator block reference page.
Introduced in R2009b