setBlockValue
Set value of tuned block parameterization in slTuner
interface
Description
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
.
Examples
Set Value of Tuned Block Parameterization
Create an slTuner
interface for the scdcascade
model, and set the value of the parameterization 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')
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 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')
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.
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);
Input Arguments
st
— Interface for tuning control systems modeled in Simulink
slTuner
interface
Interface for tuning control systems modeled in Simulink,
specified as an slTuner
interface.
blk
— Block
character vector | string
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 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 parameterization
numeric LTI model | control design block
Value of block parameterization, specified as a numeric LTI model or
a Control
Design Block, such tunableGain
or tunablePID
. 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 tunablePID
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 tunablePID
to a
three-pole tunableTF
model.
blkValues
— Values of multiple block parameterizations
structure
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
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:
getBlockParam
,getBlockValue
, andgetTunedValue
to access the tuned block parameterizations and their current values.setBlockParam
,setBlockValue
, andsetTunedValue
to modify the tuned block parameterizations and their values.writeBlockValue
to update the blocks in a Simulink model with the current values of the tuned block parameterizations.
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, usegetTunedValue
.setBlockValue
cannot be used to modify the block value. To modify the values of tuned variables within the block parameterization, usesetTunedValue
.
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
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)