Main Content

setBlockParam

Set parameterization of tuned block in slTuner interface

Description

setBlockParam lets you override the default parameterization for a tuned block in an slTuner interface. You can also specify the parameterization for non-atomic components such as Subsystem or S-Function blocks.

An slTuner interface parameterizes each tuned Simulink® block as a Control Design Block, or a generalized parametric model of type genmat or genss. This parameterization specifies the tuned variables for commands such as systune.

setBlockParam(st,blk,tunable_mdl) assigns a tunable model as the parameterization of the specified block of an slTuner interface.

example

setBlockParam(st,blk1,tunable_mdl1,...,blkN,tunable_mdlN) assigns parameterizations to multiple blocks at once.

example

setBlockParam(st,blk) reverts to the default parameterization for the block referenced by blk and initializes the block with the current block value in Simulink.

example

setBlockParam(st) reverts all the tuned blocks of st to their default parameterizations.

Examples

collapse all

Create an slTuner interface for the scdcascade model.

open_system('scdcascade')
st = slTuner('scdcascade',{'C1','C2'});

Both C1 and C2 are PI controllers. Examine the default parameterization of C1.

getBlockParam(st,'C1')
Tunable continuous-time PID controller "C1" with formula:

             1 
  Kp + Ki * ---
             s 

and tunable parameters Kp, Ki.

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

The default parameterization is a tunable PI controller (tunablePID).

Reparameterize C1 as a proportional controller. Initialize the proportional gain to 4.2, and assign the parameterization to the block.

G = tunableGain('C1',4.2);
setBlockParam(st,'C1',G);

Tuning commands, such as systune, now use this proportional controller parameterization of the C1 block of st. The custom parameterization is compatible with the default parameterization of the Simulink® block. Therefore, you can use writeBlockValue to write the tuned values back to the block.

You can also use setBlockParam to set multiple block parameterizations at once, without requiring multiple recompilations of the model. For example, reparameterize both C1 and C2 as PID controllers.

C1PID = tunablePID('C1PID','PID');
C2PID = tunablePID('C2PID','PID');
setBlockParam(st,'C1',C1PID,'C2',C2PID);

Create an slTuner interface for the scdcascade model.

open_system('scdcascade')
st = slTuner('scdcascade',{'C1','C2'});

Modify the parameterization of C2 to be a tunable gain and examine the result.

G = tunableGain('C2',5);
setBlockParam(st,'C2',G);
getBlockParam(st,'C2')
Tunable gain "C2" with 1 outputs, 1 inputs, and 1 tunable parameters.

Type "ss(ans)" to see the current value.

Revert the parameterization of C2 back to the default PI controller and examine the result.

setBlockParam(st,'C2');
getBlockParam(st,'C2')
Tunable continuous-time PID controller "C2" with formula:

             1 
  Kp + Ki * ---
             s 

and tunable parameters Kp, Ki.

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

Input Arguments

collapse all

Interface for tuning control systems modeled in Simulink, specified as an slTuner interface.

Block in the list of tuned blocks for st, specified as a character vector or string. You can specify the full block path or any portion of the block path that uniquely identifies the block among the other tuned blocks of st.

Example: blk = 'scdcascade/C1', blk = "C1"

When reverting to the default block parameterization using setBlockParam(st,blk), you can specify blk as a cell array of character vectors or string array to revert multiple blocks.

Example: {'C1','C2'}

Block parameterization, specified as one of the following:

More About

collapse all

Tuned Blocks

Tuned blocks, used by the slTuner interface, identify blocks in a Simulink model whose parameters are to be tuned to satisfy tuning goals. You can tune most Simulink blocks that represent linear elements such as gains, transfer functions, or state-space models. (For the complete list of blocks that support tuning, see How Tuned Simulink Blocks Are Parameterized). You can also tune more complex blocks such as SubSystem or S-Function blocks by specifying an equivalent tunable linear model.

Use tuning commands such as systune to tune the parameters of tuned blocks.

You must specify tuned blocks (for example, C1 and C2) when you create an slTuner interface.

st = slTuner('scdcascade',{'C1','C2'})

You can modify the list of tuned blocks using addBlock and removeBlock.

To interact with the tuned blocks use:

Tuned Variables

Within an slTuner interface, tuned variables are any Control Design Blocks involved in the parameterization of a tuned Simulink block, either directly or through a generalized parametric model. Tuned variables are the parameters manipulated by tuning commands such as systune.

For Simulink blocks parameterized by a generalized model or a tunable surface:

  • getBlockValue provides access to the overall value of the block parameterization. To access the values of the tuned variables within the block parameterization, use getTunedValue.

  • setBlockValue cannot be used to modify the block value. To modify the values of tuned variables within the block parameterization, use setTunedValue.

For Simulink blocks parameterized by a Control Design Block, the block itself is the tuned variable. To modify the block value, you can use either setBlockValue or setTunedValue. Similarly, you can retrieve the block value using either getBlockValue or getTunedValue.

Version History

Introduced in R2011b