getBlockValue

Get current value of tuned block parameterization in slTuner interface

Syntax

  • val = getBlockValue(st,blk) example
  • [val1,...,valN] = getBlockValue(st,blk1,...,blkN)
  • [val1,...,valN] = getBlockValue(st)

Description

example

val = getBlockValue(st,blk) returns the current value of the parameterization of the Simulink® block, blk.

The slTuner interface automatically associates a parametric model with each Simulink block in its list of tuned blocks. This parameterization expresses each tuned block as a Control Design Block or a tunable genss model. The parameterization specifies which parameters are tuned by commands such as systune. Use getBlockValue to access the value of this parameterization after tuning.

blk can also specify a particular tunable element of a custom parameterization of a tunable block in an slTuner interface. If you use setBlockParam to assign a custom genss model parameterization of a tuned block, setting blk to the name of a tunable element lets you query the current value of a particular tunable element of the genss model.

Use setBlockParam or writeBlockValue to align the block parameterization values with the actual block values in the Simulink model.

[val1,...,valN] = getBlockValue(st,blk1,...,blkN) returns the current values of the parameterizations of one or more blocks.

[val1,...,valN] = getBlockValue(st) returns the current values of the parameterizations of all the tuned blocks of st (in their order of appearance in st.TunedBlocks).

Examples

expand all

Get Current Parameterization Value of Tuned Block

Create an slTuner interface for the Simulink model scdcascade, and examine the current value of the block parameterization of one of the tuned blocks.

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

val = getBlockValue(st,'C1')
val =
 
             1 
  Kp + Ki * ---
             s 

  with Kp = 0.158, Ki = 0.042
 
Name: C1
Continuous-time PI controller in parallel form.

Query Value of Single Tunable Element within Custom Parameterization

Create an slTuner interface for the scdcascade model. Set a custom parameterization of one of the tunable blocks.

open_system('scdcascade');
st = slTuner('scdcascade',{'C1','C2'});
C1CustParam = realp('Kp',1) + tf(1,[1 0]) * realp('Ki',1);
setBlockParam(st,'C1',C1CustParam);

These commands set the parameterization of the C1 controller block to a generalized state-space (genss) model containing two tunable parameters, 'Ki' and 'Kp'..

Initialize the value of Ki to 10, without changing the current value of 'Kp'

setBlockValue(st,'Ki',10);

Typically, you would use a tuning command such as systune to tune the values of the parameters in the custom parameterization. After tuning, use getBlockValue to query the tuned value of 'Ki' as follows.

KiTuned = getBlockValue(st,'Ki');

Input Arguments

expand 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 — Block or tunable elementstring

Block in the list of tuned blocks for st or tunable element of custom parameterization, specified as a 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.

For example, blk = 'scdcascade/C1' or blk = 'C1'.

blk can also specify a particular tunable element of a custom parameterization of a tunable block in an slTuner interface. If you use setBlockParam to assign a custom genss model parameterization of a tuned block, setting blk to the name of a tunable element lets you query the current value of a particular tunable element of the genss model.

Output Arguments

expand all

val — Current value of block parameterizationnumeric LTI model

Current value of block parameterization, returned as a numeric LTI model such as pid, ss, or tf.

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 commands such as systune and looptune 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. Use commands such as setBlockParam, getBlockValue, and writeBlockValue to interact with and manipulate tuned blocks.

Was this topic helpful?