| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → SimMechanics |
| Contents | Index |
| Learn more about SimMechanics |
Bodies
The Machine Environment block allows you to view and change the mechanical environment settings for one machine in your model.
Caution A SimMechanics model consists of one or more machines. A machine is a complete, connected diagram of SimMechanics blocks topologically distinct from other complete SimMechanics block diagrams. Each machine must have one or more Ground blocks. A machine can be a composite of submachines connected by Shared Environment blocks. Each submachine must have one or more Ground blocks. Exactly one Ground per machine, simple or composite, must be connected to a Machine Environment block for your SimMechanics model to be valid. |
This block determines the following settings for the machine:
How to simulate the machine
How to interpret mechanical constraints
How to linearize the simulation
Whether and how to display the machine in visualization
You connect this block to a Ground by enabling that Ground's Machine Environment port from the Ground dialog.

This block also allows you to input gravity as a variable Simulink signal. If you choose to do this, a Simulink inport > also appears on the block for connection to a three-component Simulink signal line.
You can open the Simulink Configuration Parameters dialog for viewing and editing by clicking the Configuration Parameters button on the lower left of the block dialog.
In the lower half of its dialog, the Machine Environment block has four active tabs that you can view and modify after selecting the corresponding tabs. You can apply your settings at any time by clicking Apply or OK.


In this tab, you configure settings that control the mechanical dynamics.
The value of this parameter is a MATLAB vector that specifies the magnitude and direction of gravitational acceleration in the model's world coordinate system. It must be a three-component vector. The default vector is [0 -9.81 0]. This field is disabled if you choose to input gravity as a signal.
The default units are m/s2 (meters per square second). Use the pull-down menu to the right if you want to reset the units.
Select this check box if you want to disable the Gravity vector field and instead input gravity as a variable Simulink signal. The default is not selected.
If you select this check box, a Simulink inport appears on the block in addition to the existing Machine Environment port. You input the gravity vector as a three-component Simulink signal to this port. The components are, respectively, x, y, and z.

In the pull-down menu, select in how many dimensions you want to simulate your machine: in 3D Only or 2D Only, or let the SimMechanics simulation choose for you with Auto. The default is 3D Only.
You must take care, if you choose 2D Only, that the machine actually moves in only two dimensions. If it does not, the simulation stops with an error.
Specifies the type of analysis to be performed during the simulation. Choose one from the pull-down menu.
| Analysis Mode | Description |
|---|---|
| Forward dynamics | Computes the positions and velocities of the system's bodies, given forces, torques, and initial conditions. This is the default mode. |
| Inverse dynamics | Computes the forces and torques required to produce the specified motions of an open machine. |
| Kinematics | Computes the forces and torques required to produce the specified motions of a closed-loop machine. |
| Trimming | Variant of Forward Dynamics mode to be used with the Simulinktrim command. Determines steady-state or other points in system state space. |
Maximum position error allowed between bodies connected by prismatic joints. The default is 1e-3 m. Use the menu on the right to set the units.
Maximum angular error allowed between bodies connected by revolute joints. Default is 1e-3 rad. Use the menu on the right to set the units.

In this tab, you tell the SimMechanics simulation how to interpret mechanical constraints in machines that contain blocks from the Constraints & Drivers library; cut Joint, Constraint, and Driver blocks in closed loops; or both.
Type of solver used to solve constraints on the mechanical system's states. Choose one from the pull-down menu.
| Solver Type | Description |
|---|---|
| Stabilizing | Adds a self-correcting term to the dynamics that stabilizes the numerical solution so that it drifts toward the constraint manifold. This is the default. |
| Tolerancing | Solves the constraints on the system's states to a specified degree of accuracy. |
| Machine precision | Solves the constraints to the numerical precision of the computer on which the simulation is running. |
The relative tolerance used by the tolerancing constraint solver to determine when to stop refining a solution. Default is 1e-4.
Enabled only if Constraint solver type is set to Tolerancing.
The absolute tolerance used by the tolerancing constraint solver to determine when to stop refining the solution of a machine state. Default is 1e-4.
Enabled only if Constraint solver type is set to Tolerancing.
Select this check box if you want Simulink to take extra steps to handle singularities in a system's equations of motion. The default is not selected.
This option increases the computational cost of solving a system's equations of motion, regardless of whether they have singularities. Select this option only as a last resort, i.e., only if the Simulink solvers cannot otherwise solve the system's equations of motion or require an excessively long time to do so.
Select Specify tolerance in this pull-down menu if you want to control how precisely the SimMechanics simulation distinguishes constraints. The default is Automatically select tolerance.
This option is important if you have two or more constraints that impose almost identical restrictions on the motion of your machine. More constraints means fewer degrees of freedom.
If two or more constraints are almost the same, the simulation eliminates one or more of them as redundant.
If the constraints are dissimilar enough, the simulation treats them as independent constraints.
Selecting Specify tolerance enables the Relative tolerance field.
The relative tolerance of redundant constraint analysis that the simulation implements. This field is enabled only if you select Specify tolerance in the Redundant constraint tolerancing pull-down menu. The default is 1e-14.
Making this tolerance larger means the simulation treats similar constraints as the same, i.e., redundant.
Making this tolerance smaller means the simulation treats similar constraints as distinct, i.e., not redundant.

In this tab, you tell the simulation how to linearize your machine.
Specifies the type of state perturbation used by linmod to linearize a machine. The default is Fixed.
Adaptive recomputes the size of the perturbation used at each step in the linearization process to ensure accurate computation of the linearization coefficients. It starts with the entry in the Perturbation size field as an initial guess.
Fixed uses the perturbation size specified in the Perturbation size field for every step.
Specifies the relative size of the perturbation used by the Fixed perturbation option. Specifies the relative size of the initial guess perturbation used by the Adaptive perturbation type. The perturbation size is relative to the size of the state being perturbed. The default is 1e-5.

In this tab, you determine whether SimMechanics visualization displays this machine and choose the default body geometry (surface shape) and color for all the Bodies within the connected machine.
The machine inherits the model-wide defaults for body geometry and color. But you can change these machine-wide defaults to differ from the model-wide defaults.
Select this check box if you want the machine to which this block is connected to appear in the visualization window. The default is selected.
From the pull-down menu, select a machine-wide default body geometry.
Use model default body geometries (the default)
Convex hull from Body CS locations for convex hulls
Equivalent ellipsoid from mass properties for equivalent ellipsoids
From the pull-down menu, choose whether to use the model-wide default for the color of all Bodies in this machine (the default), or to specify a machine-wide default different from the model-wide default.
If you select Specify in the Body color selection mode pull-down menu, you can specify the machine-wide default body color in the field. You specify RGB values according to the MATLAB Graphics ColorSpec.
The default is [1 0 0].

Body, Ground, Shared Environment
See the relevant entries in the Glossary: constraint, dynamics, ground, kinematics, machine, machine precision constraint, stabilizing constraint, and tolerancing constraint.
For more about SimMechanics models and machines, see Representing Machines with Models. For more about using Grounds and creating valid SimMechanics models, see Modeling Grounds and Bodies and Validating Mechanical Models. For more about modeling constraints, see Constraining and Driving Degrees of Freedom.
The Analyzing Motion chapter presents an in-depth look at the SimMechanics motion analysis modes.
For more about configuring visualization for simulation, see Starting Visualization and Simulation. For complete information about machine and body visualization, including default and custom body geometries and colors, see the SimMechanics Visualization and Import Guide.
For more about running SimMechanics software with Simulink, see Configuring SimMechanics Models in Simulink, Machine Settings via the Machine Environment Block, and Configuring Methods of Solution.
For more about configuring simulations in Simulink, consult the section on the Configuration Parameters dialog in the Simulink documentation.
![]() | Linear Driver | Mechanical Branching Bar | ![]() |

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 |