This example shows how to optimize controller parameters to track a reference signal using the Response Optimization tool. You specify the reference signal without adding any Check blocks to the model.
sldo_model1 includes these blocks:
Controller block, a PID controller,
controls the output of the
Unit Step block applies a step input.
You can also use other types of inputs, such as ramp, to optimize the response generated by such inputs.
The model output must track a reference signal , where t is time.
Open the Simulink® model.
sys = 'sldo_model1'; open_system(sys);
To learn more about the model, see Model Structure.
To open the Response Optimization tool, select Analysis > Response Optimization.
Select the model signal to track the reference signal.
In the New drop-down list, select Signal to open the Create Signal Set window.
To display the signal in the window, click the output of the Plant block in the Simulink model window.
Select the signal, and click to add it to the signal set.
In Signal set, enter
PlantOutput as the
selected signal name.
Click OK to create the variable
appears in the Data area of the Response Optimization tool.
Specify the reference signal for the model output to track.
In the New drop-down list, select Signal Tracking to open a Create Requirement window.
In the Name edit box, enter
In the Time vector edit box, enter
In the Amplitude edit box, enter
Leave the Tracking Method as
means, at each optimization iteration, the solver attempts to reduce the sum of squared
errors between the simulated output and reference signal.
Click Update reference signal data.
In the Specify Signal to Track Reference Signal area, select the check-box corresponding to the signal you selected in the previous step, and click OK.
A new reference signal
ref_sig is created and appears in the
Data area. The Response Optimization window updates to plot the
When you optimize the model response, the software modifies the design variable values to meet the design requirements.
In the Response Optimization tab:
Create a new set of design variables.
In the Design Variables Set drop-down list select New.
The Create Design Variables Set window shows model parameters that you can use as design variables and indicates their locations within the model subsystems.
Add parameters to the design variables set.
and click to
add the selected parameters.
The design variables list displays the following parameter settings:
Variable — Parameter name
Value — Current parameter value
Minimum and Maximum — Parameter bounds
Scale — Scaling factor for the parameter
Limit the parameters to positive values. To do so, enter
0 for the
minimum value of each parameter in the corresponding Minimum field, and
press Enter on your keyboard.
Click OK. A new design variable
created and appears in the Data area of the Response Optimization
To view the current model response, click Plot Model Response.
The plot shows that the model response does not track the reference signal.
At each iteration, the optimization solver
fmincon) modifies the controller parameters to minimize the error between the
simulated response and the reference signal. To learn more, see How the Optimization Algorithm Formulates Minimization Problems.
Optimization converged in the Optimization Progress Report
indicates that the optimization method found a solution that tracks the reference signal
within the tolerances and parameter bounds. For more information about the outputs displayed
in the Optimization Progress Report, see Iterative Display (Optimization Toolbox).
Verify that the response tracks the reference signal by observing the amplitude versus time plot.
The optimized response closely tracks the reference signal.
To view the optimized parameter values, click
DesignVars in the
Data area of the Response Optimization tool. View the updated values in
the Variable Preview area.
The optimized values of the design variables are automatically updated in the Simulink model.