Simscape Multibody states from Simulink state vector


[vector_mgr, mech_states] = mech_get_states(X, block)
[vector_mgr, mech_states] = mech_get_states(X, vectorMgr)



This content is specific to Simscape™ Multibody™ First Generation software. First-generation features are slated to be deprecated and should be avoided.

[vector_mgr, mech_states] = mech_get_states(X, block) returns a state vector manager object. The object's values reflect the Simscape Multibody states in the Simulink® state vector X for the Simscape Multibody machine containing block. The function also returns the mechanical states vector_mgr.X in mech_states.

[vector_mgr, mech_states] = mech_get_states(X, vectorMgr) extracts the mechanical states from the Simulink state vector X and returns them as an array of states assigned to vector_mgr.X.

The returned vector manager is an instance of the MECH.StateVectorMgr class, the same class as returned by the mech_stateVectorMgr function.

Input Arguments

mech_get_states accepts two possible combinations of two inputs.


The Simulink state vector for your model. X must be compatible with your Simulink model.


A string or block handle specifying the absolute path of a block in the machine that you want to query.


A mechanical state vector manager object of the MECH.StateVectorMgr class.

Output Arguments

mech_get_states produces one or two outputs.


An instance of the MECH.StateVectorMgr object class whose values reflect the mechanical state of the model.


A vector of the mechanical state values. Identical to vector_mgr.X, if you use the first form of the function.


Assigning a Final Model State

Simulate a Stewart platform model for 10 seconds, capturing the model state over the entire simulation:

simOut = sim('mech_stewart_trajectory','StopTime','10', ...
xout = simOut.get('xout');

Populate the state vector manager with this model's final state:

stewartStateVectorMgr = mech_get_states(xout(end,:), ...
   'mech_stewart_trajectory/Plant/Machine Environment');

Introduced before R2006a

Was this topic helpful?