getTunedValue
Get current value of tuned variable in slTuner
interface
Syntax
Description
getTunedValue
lets you access the
current value of a tuned
variable within an slTuner
interface.
An slTuner
interface parameterizes each tuned 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
Query Value of Single Tunable Element within Custom Parameterization
Create an slTuner
interface for the scdcascade
model.
open_system('scdcascade') st = slTuner('scdcascade',{'C1','C2'});
Set a custom parameterization for one of the tunable blocks.
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
.
Typically, you would use a tuning command such as systune
to tune the values of the parameters in the custom parameterization.
After tuning, use getTunedValue
to query the tuned value of Ki
.
KiTuned = getTunedValue(st,'Ki')
KiTuned = 1
To query the value of the tuned block as a whole, C1
, use getBlockValue
.
Query Value of Multiple Tunable Elements Within Custom Parameterization
Create an slTuner
interface for the scdcascade
model.
open_system('scdcascade') st = slTuner('scdcascade',{'C1','C2'});
Set a custom parameterization for one of the tunable blocks.
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 tunable parameters Kp
and Ki
.
Typically, you would use a tuning command such as systune
to tune the values of the parameters in the custom parameterization.
After tuning, use getTunedValue
to query the tuned values of both Kp
and Ki
.
[KiTuned,KpTuned] = getTunedValue(st,'Ki','Kp')
KiTuned = 1 KpTuned = 1
Query Value of All Tuned Elements in slTuner Interface with Custom Parameterizations
Create an slTuner
interface for the scdcascade
model.
open_system('scdcascade') st = slTuner('scdcascade',{'C1','C2'});
Set a custom parameterization for tuned block C1
.
C1CustParam = realp('Kp',1) + tf(1,[1 0]) * realp('Ki',1); setBlockParam(st,'C1',C1CustParam);
Typically, you would use a tuning command such as systune
to tune the values of the parameters in the custom parameterization.
After tuning, use getTunedValue
to query the tuned values of the parameterizations of all the tuned blocks in st
.
S = getTunedValue(st)
S = struct with fields: C2: [1x1 pid] Ki: 1 Kp: 1
The tuned values are returned in a structure that contains fields for:
The tuned block,
C2
, which is parameterized as a Control Design Block.The tunable elements,
Kp
andKi
, within blockC2
, which is parameterized as a customgenss
model.
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.
var
— Tuned variable
character vector | string
Tuned variable within st
, specified as
a character vector or string. A tuned variable is any Control Design
Block, such realp
, tunableSS
,
or tunableGain
, involved in the parameterization
of a tuned Simulink block, either directly or through a generalized
parametric model. To get a list of all tuned variables within st
,
use getTunedValue(st)
.
var
can refer to the following:
For a block parameterized by a Control Design Block, the name of the block. For example, if the parameterization of the block is
C = tunableSS('C')
then set
var
='C'
.For a block parameterized by a
genmat
/genss
model,M
, the name of any Control Design Block listed inM.Blocks
. For example, if the parameterization of the block isa = realp('a',1); C = tf(a,[1 a]);
then set
var
='a'
.
Output Arguments
value
— Current value of tuned variable
numeric scalar | numeric array | state-space model
Current value of tuned variable in st
,
returned as a numeric scalar or array or a state-space model. When
the tuning results have not been applied to the Simulink model
using writeBlockValue
, the value returned by getTunedValue
can
differ from the Simulink block value.
Note
Use writeBlockValue
to
align the block parameterization values with the actual block values
in the Simulink model.
S
— Current values of all tuned variables
structure
Current values of all tuned variables in st
,
returned as a structure. The names of the fields in S
are
the names of the tuned variables in st
, and the
field values are the corresponding numeric scalars or arrays.
You can use this structure to transfer the tuned variable values
from one slTuner
interface to another slTuner
interface
with the same tuned variables, as follows:
S = getTunedValue(st1); setTunedValue(st2,S);
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 R2015b
See Also
slTuner
| setTunedValue
| getBlockParam
| getBlockValue
| tunableSurface
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)