| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → SimMechanics |
| Contents | Index |
| Learn more about SimMechanics |
X = mech_runtime_states(vectorMgr)
[X, RTO] = mech_runtime_states(vectorMgr)
[X, RTO] = mech_runtime_states(vectorMgr, RTO)
X = mech_runtime_states(vectorMgr) returns the vector of instantaneous SimMechanics states in the machine associated with the state vector manager vectorMgr in an executing model. The contents of vectorMgr are not altered.
[X, RTO] = mech_runtime_states(vectorMgr) also returns the Simulink runtime object (RTO) that contains the SimMechanics states. You can use this form to speed up future calls to this function.
[X, RTO] = mech_runtime_states(vectorMgr, RTO) uses the Simulink runtime object RTO assumed to correspond to the machine associated with vectorMgr. This form of the function is faster than the others.
The returned value X has a format that you can assign to vectorMgr.X, which you can then use to interpret the states.
mech_runtime_states accepts one or two inputs.
vectorMgr |
A mechanical state vector manager as returned by the mech_stateVectorMgr function. This input is required. |
RTO |
A Simulink runtime object that corresponds to the machine referenced by vectorMgr. This input is optional. |
mech_runtime_states produces one or two outputs.
X |
The vector of mechanical state values at the instant you query the running model. |
RTO |
A Simulink runtime object. |
Enter the following script at the command line.
modelName = 'mech_stewart_trajectory';
open(modelName);
groundBlock = find_system(modelName, 'Name', 'Ground1');
vm = mech_stateVectorMgr(groundBlock{1});
set_param(modelName, 'SimulationCommand', 'Start')
[vm.X, rto] = mech_runtime_states(vm)
try
while (true)
vm.X = mech_runtime_states(vm, rto);
clc;
vm.BlockStates(1) % display
pause(0.5);
end
catch myException
set_param(modelName, 'SimulationCommand', 'Stop')
throw(myException), throwAsCaller(myException);
end
set_param(modelName, 'SimulationCommand', 'Stop')
This script displays and updates the state of the first Joint in the Stewart platform model, mech_stewart_trajectory. The results appear in the command window. Press Ctrl+C at the keyboard to halt the simulation. (Ignore the error message that results.)
mech_get_states | mech_set_states | mech_stateVectorMgr | mech_transfer_states | sim | states
![]() | mech_import | mech_set_states | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |