SimMechanics    

Linearizing SimMechanics Models

The Simulink linmod command creates linear time-invariant (LTI) state-space models from Simulink models. You can use this command to generate an LTI state-space model from a SimMechanics model, for example, to serve as input to Control System Toolbox commands that generate controller models. The linmod command allows you to specify the point in state space about which it linearizes the model (the operating point). You should choose a point where your model is in equilibrium, i.e., where the net force on the model is zero. You can use the Simulink trim command to find a suitable operating point (see Trimming Mechanical Systems). By default linmod uses an adaptive perturbation method to linearize a SimMechanics model. The Mechanical Environment Settings dialog box allows you to specify that linmod use a fixed perturbation method instead (see Linearization Pane). The following example illustrates the use of linmod to linearize a SimMechanics model.

Model Linearization Example: Double Pendulum

Consider a double pendulum initially hanging straight up and down.

The net force on the pendulum is zero in this configuration. The pendulum is thus in equilibrium.

The following figure shows a SimMechanics demo model of the pendulum, mech_dpend_forw.

To linearize this model, enter

at the MATLAB command line. This form of the linmod command linearizes the model about the model's initial states.

The matrices A, B, C, D returned by the linmod command correspond to the standard mathematical representation of an LTI state-space model:

where x is the model's state vector, y is its outputs, and u is its inputs. The double pendulum model has no inputs or outputs. Consequently, only A is not null. This reduces the state-space model for the double pendulum to

where

This model specifies the relationship between the state derivatives and the states of the double pendulum. The state vector of the LTI model has the same format as the state vector of the SimMechanics model. The SimMechanics mech_stateVectorMgr command gives the format of the state vector as follows:

Multiplying A by the state vector x yields the differential state equations corresponding to the LTI model of the double pendulum.



where

    



The following Simulink model implements the state space model represented by these equations.

This model in turn allows creation of a model, located in mech_dpend_lin, that computes the LTI approximation error.

Running the model twice with the upper joint deflected 2 degrees and 5 degrees, respectively, shows an increase in error as the initial state of the system strays from the pendulum's equilibrium position and as time elapses. This is the expected behavior of a linear state-space approximation.


  Constrained Example: Four-Bar System How SimMechanics Works