Main Content

getstatestruct

Obtain state values from operating point

Description

example

x = getstatestruct(op) extracts a structure of state values from a specified operating point object. You can use the state structure to set initial state values for your Simulink® model.

Examples

collapse all

Open the scdplane model and create an operating point. You can also compute a trimmed operating point or obtain an operating point snapshot.

mdl = 'scdplane';
open_system(mdl)
op = operpoint(mdl);

Extract the state values from the operating point.

xInitial = getstatestruct(op);

Extract the input values from the operating point.

uInitial = getinputstruct(op);

To view the values of the states or inputs within this structure, use dot notation. For example, view the input values.

uInitial.signals.values
ans = 0

Set the initial state values in the model.

set_param(mdl,'LoadInitialState','on','InitialState','xInitial')

Set the initial input values in the model.

set_param(mdl,'LoadExternalInput','on','ExternalInput','uInitial')

Input Arguments

collapse all

Operating point for a Simulink model, specified as an OperatingPoint, OperatingSpec, or OperatingReport object. You can also specify a homogeneous array of any of these objects.

Output Arguments

collapse all

State values, returned as a structure with the following fields.

  • signals — State values and information

  • time — Simulation time for state values, returned as 0.

If op is an array, x is returned as a structure array with the same dimensions as op.

Version History

Introduced before R2006a