Main Content

setBlockValue

Modify value of Control Design Block in Generalized Model

Description

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. The values of blocks of M0 not listed in blockvalues do not change.

example

M = setBlockValue(M0,Mref) assigns values from Control Design Blocks in the Generalized Model Mref to blocks in M0.

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

Examples

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 command embeds the tuned controller parameters 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 by using the systune function.

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 = 60

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)
Tunable continuous-time PID controller "C0" with formula:

             1 
  Kp + Ki * ---
             s 

and tunable parameters Kp, Ki.

Type "pid(C)" to see the current value.

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 by using the getValue function. This function returns a numeric state-space model of the tuned controller.

 CVal = getValue(C,T)
CVal =
 
  A = 
             C0.Integ
   C0.Integ         0
 
  B = 
             u1
   C0.Integ   1
 
  C = 
       C0.Integ
   y1  0.005249
 
  D = 
              u1
   y1  0.0004327
 
Name: C0
Continuous-time state-space model.

Input Arguments

collapse all

Generalized LTI model or matrix, specified as a genss object, genfrd object, or a genmat object. For more information on generalized LTI models, see Generalized and Uncertain LTI Models. For more information on generalized matrices, see Generalized Matrices.

Name of a Control Design Block in input model M, specified as a character vector.

Example: To get a list of the Control Design Blocks in input model M0, enter M0.Blocks at the command prompt.

Replacement value for the Control Design Block blockname, specified as a scalar. val replaces the current or nominal value of blockname, and 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.

Replacement values for Control Design Blocks of input model M0, specified as a structure. The fields of the structure must match the names of the blocks to modify. The value of each field specifies the replacement current or nominal value for the corresponding block.

Generalized reference model, specified as a genss object or a genmat object. The generalized model Mref must share one or more Control Design Blocks with the input model M0. The function uses the values of blocks in Mref to update the values of the corresponding blocks in M0.

Output Arguments

collapse all

Generalized LTI model, returned as a genss object obtained from the input model M0, with updated block values.

Version History

Introduced in R2011b

See Also

| | | | | | (Robust Control Toolbox)