| Contents | Index |
This example shows how to optimize controller parameters to track a reference signal using the Design Optimization tool. You specify the reference signal without adding any Check blocks to the model.
The model sldo_model1 includes the following blocks:

Controller block, which is a PID controller. This block controls the output of the Plant subsystem.
Unit Step block applies a step input and produces the model output that should meet step response requirements.
You can also use other types of inputs, such as ramp, to optimize the response to meet step response requirements generated by such inputs.
Plant subsystem is a second-order system with delay. It contains Transfer Function and Transport Delay blocks.

The model output must track a reference signal
, where t is
time.
Open Simulink model.
sys = 'sldo_model1'; open_system(sys);

To learn more about the model, see Model Structure.
In the Simulink model window, select Tools > Response Optimization.
A Design Optimization tool for the model opens.

Select the model signal which must track the reference signal.
In the New drop-down list, select Signal.

A window opens where you select a model signal.

In the Simulink model window, click the output of the Plant block.
The window updates to display the selected signal.

Select the signal and click
to add it to the signal
set.

In Signal set, enter PlantOutput as the selected signal name.
Click OK. A new variable PlantOutput appears in the Design Optimization Workspace of the Design Optimization tool.
Specify the reference signal that the model output must track.
In the New drop-down list, select Signal Tracking.

A window opens where you specify the reference signal.

In Requirement Name, enter ref_sig.
In Time vector, enter linspace(0,50,200)
In Amplitude, enter 1-exp(-0.1*linspace(0,50,200)).

The Tracking Method is SSE which means that 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.
Select the check-box corresponding to the signal you selected in the previous step in the Select Model Signals area.

Click OK. A new variable ref_sig appears in the Design Optimization Workspace and the Design Optimization window updates to plot the reference signal.

Before you begin this task, specify the reference signal to track as described in Specify Reference Signal.
When you optimize the model response, the software modifies the design variable (model parameter) values to meet the design requirements.
In the Response Optimization tab:
Select New in the Design Variables Set drop-down list.

A window opens where you specify design variables.

Click Kd, Ki and Kp to select them.
Click
to add the selected parameters
to a design variables set.

The software displays the following parameter settings:
Variable — Parameter name
Value — Current parameter value
Minimum and Maximum — Parameter bounds
Scale — Scaling factor for the parameter
The check-box indicates that the parameter is included in the design variable set. The default design variable set name is DesignVars.
To limit the parameters to positive values, enter the minimum value of each parameter as 0 in the corresponding Minimum field and press Enter.

Click OK. A new variable DesignVars appears in Design Optimization Workspace of the Design Optimization tool. You can click the variable to view its contents in the Variable Preview area.

Before you begin this task, you must have specified the reference signal to track and design variables, as described in Specify Reference Signal and Specify Design Variables, respectively.
(Optional) View the current model response. Click
.

The plot shows that the response does not track the reference signal.
Click Optimize.

An optimization progress window opens.
Tip
To view the model response and optimization progress windows
simultaneously, tile them using the plot layout area
|
At each iteration, the optimization solver Gradient descent (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.
After the optimization completes, the optimization progress window resembles the following figure.

The message Optimization converged 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 window, see Iterative Display in the Optimization Toolbox documentation.
Verify that the response tracks the reference signal.

The optimized response closely tracks the reference signal.
View the optimized parameter values. Click DesignVars in Design Optimization Workspace and view the updated values in the Variable Preview area.
The optimized values of the design variables are automatically updated in the Simulink model.
![]() | Optimize Controller Parameters to Meet Step Response Requirements (Code) | Design Optimization to Meet Frequency-Domain Requirements (GUI, with Check Block) | ![]() |

Learn more about resources for designing, testing, and implementing control systems.
Get free kit| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |