Main Content


Modify value of Control Design Block in Generalized Model


M = setBlockValue(M0,blockname,val)
M = setBlockValue(M0,blockvalues)
M = setBlockValue(M0,Mref)


M = setBlockValue(M0,blockname,val) modifies the current or nominal value of the Control Design Block blockname in the Generalized Model M0 to the value specified by val.

M = setBlockValue(M0,blockvalues) modifies the value of several Control Design Blocks at once. The structure blockvalues specifies the blocks and replacement values. Blocks of M0 not listed in blockvalues are unchanged.

M = setBlockValue(M0,Mref) takes replacement values from Control Design blocks in the Generalized Model Mref. This syntax modifies the Control Design Blocks in M0 to match the current values of all corresponding blocks in Mref.

Use this syntax to propagate block values, such as tuned parameter values, from one parametric model to other models that depend on the same parameters.

Input Arguments


Generalized Model containing the blocks whose current or nominal value is modified to val. For the syntax M = setBlockValue(M0,Mref) M0 can be a single Control Design Block whose value is modified to match the value of the corresponding block in Mref.


Name of the Control Design Block in the model M0 whose current or nominal value is modified.

To get a list of the Control Design Blocks in M0, enter M0.Blocks.


Replacement value for the current or nominal value of the Control Design Block, blockname. The value val can be any value that is compatible with blockname without changing the size, type, or sample time of blockname.

For example, you can set the value of a tunable PID block (tunablePID) to a pid controller model , or to a transfer function (tf) model that represents a PID controller.


Structure specifying Control Design Blocks of M0 to modify, and the corresponding replacement values. The fields of the structure are the names of the blocks to modify. The value of each field specifies the replacement current or nominal value for the corresponding block.


Generalized Model that shares some Control Design Blocks with M0. The values of these blocks in Mref are used to update their counterparts in M0.

Output Arguments


Generalized Model obtained from M0 by updating the values of the specified blocks.


collapse all

Propagate the values of tuned parameters to other Control Design Blocks.

You can use tuning commands such as systune, looptune, or the Robust Control Toolbox™ command hinfstruct to tune blocks in a closed-loop model of a control system. If you do so, the tuned controller parameters are embedded in a generalized model. You can use setBlockValue to propagate those parameters to a controller model.

Create a tunable model of the closed-loop response of a control system, and tune the parameters using systune.

s = tf('s');
num = 33000*(s^2 - 200*s + 90000);
den = (s + 12.5)*(s^2 + 25*s + 63000);
G = num/den;

C0 = tunablePID('C0','pi');
a = realp('a',1);
F0 = tf(a,[1 a]);
T0 = feedback(G*C0,F0);
T0.InputName = 'r';
T0.OutputName = 'y';

T0 is a generalized model of the closed-loop control system and contains two tunable blocks:

  • C0 - Tunable PID controller

  • a - Real tunable parameter

Create a tuning requirement for the output y to track the input r, and tune the system to meet that requirement.

Req = TuningGoal.Tracking('r','y',0.05);
[T,fSoft,~] = systune(T0,Req);
Final: Soft = 1.43, Hard = -Inf, Iterations = 59

The generalized model T contains the tuned values of C0 and a.

Propagate the tuned values of the controller in T to the controller model C0.

C = setBlockValue(C0,T)
C = 
  Tunable continuous-time PID controller "C0" with formula:

  Kp + Ki * ---

  and tunable parameters Kp, Ki.

Type "pid(C)" to see the current value and "get(C)" to see all properties.

C is still a tunablePID controller. The current PID gains in C are set to the values of the controller in T.

Obtain a numeric LTI model of the tuned controller using getValue.

 CVal = getValue(C,T);

This command returns a numerical state-space model of the tuned controller.

See Also

| | | | | | (Robust Control Toolbox)

Introduced in R2011b