Documentation

setBlockValue

Set value of tuned block parameterization in slTuner interface

setBlockValue lets you initialize or modify the current value of the parameterization of a tuned block in an slTuner interface.

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.

Syntax

  • setBlockValue(st,blk,value)
    example
  • setBlockValue(st,blkValues)
    example

Description

example

setBlockValue(st,blk,value) sets the current value of the parameterization of a block in the slTuner interface, st.

example

setBlockValue(st,blkValues) updates the values of the parameterizations of multiple blocks using the structure, blkValues.

Examples

collapse all

Set Value of Tuned Block Parameterization

Create an slTuner interface for the scdcascade model, and set the value of the parametrization of one of the tuned blocks.

Create an slTuner interface.

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

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

getBlockParam(st,'C1')
ans =

  Parametric continuous-time PID controller "C1" with formula:

             1 
  Kp + Ki * ---
             s 

  and tunable parameters Kp, Ki.

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

The default parameterization is a PI controller with two tunable parameters, Kp and Ki.

Set the value of the parameterization of C1.

C = pid(4.2);
setBlockValue(st,'C1',C);

Examine the value of the parameterization of C1.

getBlockValue(st,'C1')
ans =
 
  Kp = 4.2
 
Name: C1
P-only controller.

Examine the parameterization of C1.

getBlockParam(st,'C1')
ans =

  Parametric continuous-time PID controller "C1" with formula:

             1 
  Kp + Ki * ---
             s 

  and tunable parameters Kp, Ki.

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

Observe that although the current block value is a P-only controller, the block parameterization continues to be a PI-controller.

Set Value of Multiple Tuned Block Parameterizations

Create an slTuner interface.

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

Create a block value structure with field names that correspond to the tunable blocks in st.

blockValues = getBlockValue(st);
blockValues.C1 = pid(0.2,0.1);
blockValues.C2 = pid(2.3);

Set the values of the parameterizations of the tunable blocks in st using the defined structure.

setBlockValue(st,blockValues);

Related Examples

Input Arguments

collapse all

st — Interface for tuning control systems modeled in SimulinkslTuner interface

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

blk — Blockstring

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

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

    Note:   setBlockValue allows you to modify only the overall value of the parameterization of blk. To modify the values of elements within custom block parameterizations, such as generalized state-space models, use setTunedValue.

value — Value of block parameterizationnumeric LTI model | control design block

Value of block parameterization, specified as a numeric LTI model or a Control Design Block, such ltiblock.gain or ltiblock.pid. The value of value must be compatible with the parameterization of blk. For example, if blk is parameterized as a PID controller, then value must be an ltiblock.pid block, a numeric pid model, or a numeric tf model that represents a PID controller.

setBlockValue updates the value of the parameters of the tuned block based on the parameters of value. Using setBlockValue does not change the structure of the parameterization of the tuned block. To change the parameterization of blk, use setBlockParam. For example, you can use setBlockParam to change a block parameterization from ltiblock.pid to a three-pole ltiblock.tf model.

blkValues — Values of multiple block parameterizationsstructure

Values of multiple block parameterizations, specified as a structure with fields specified as numeric LTI models or Control Design Blocks. The field names are the names of blocks in st. Only blocks common to st and blkValues are updated, while all other blocks in st remain unchanged.

To specify blkValues, you can retrieve and modify the block parameterization value structure from st.

blkValues = getblockValue(st);
blkValues.C1 = pid(0.1,0.2);

    Note:   For Simulink blocks whose names are not valid field names, specify the corresponding field name in blkValues as it appears in the block parameterization.

    blockParam = getBlockParam(st,'B-1');
    fieldName = blockParam.Name;
    blockValues = struct(fieldName,newB1);

More About

expand 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.

Introduced in R2011b

Was this topic helpful?