MATLAB: How to get the derivatives of the states of SimMechanics and Simulink blocks in Simulink 7.3 (R2009a)

derivativemodelSimscape Multibodystate

I have a SimMechanics model and I wish to get the derivative of the state of a block at a given time or state. How can I do this?

Best Answer

You can do this with the MODEL function as described in the documentation here:
<http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/slref/model_cmd.html>
The following is a short example that illustrates this for the "mech_bouncing_ball" example.
mech_bouncing_ball
[sys,x0,str,ts]=mech_bouncing_ball([],[],[],'compile')
outputs = mech_bouncing_ball(0,[0 0],[],'outputs')
derivs = mech_bouncing_ball(0,[0 0],[],'derivs')
mech_bouncing_ball([],[],[],'term')