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
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
.
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
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: [1×1 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
Interface for tuning control systems modeled in Simulink,
specified as an slTuner
interface.
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
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.
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, 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.
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.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)