index1 =
1 2
You can also obtain the indices of a subset of the block states by specifying the element
index as a vector. For example, get the indices for the first and third states in the
specification for the system1 block.
index2 = getStateIndex(opspec,'scdindex1/system1',[1 3])
index2 =
1 1
1 3
Get Index of Named State from Operating Point Specification
Open Simulink model.
mdl = 'scdindex2';
mdlpath = fullfile(matlabroot,'examples','slcontrol',mdl);
open_system(mdlpath)
The system1 block is a state-space system with three named states: position,
velocity, and acceleration.
Create an operating point specification for the model.
opspec = operspec(mdl);
The States property of the operating point specification object contains one entry for
each named state in system1.
getStateIndex