SimMechanics    

Visualizing a Simple Pendulum

In this section, you learn how to view the swinging pendulum rod of the model introduced in the last section using the SimMechanics visualization tools. Use your saved spen.mdl model, or use the mech_spen model in the Demos library. Online Help users can click here to open the model.

SimMechanics has two independent tools for visualizing a machine. One is an internal tool based on MATLAB Handle Graphics. The other is an optional virtual reality scene and requires the Virtual Reality Toolbox 3.0 to be installed. Both tools display a machine by representing its bodies. The bodies can be displayed in two ways, by equivalent ellipsoids and by closed surfaces (convex hulls) enveloping the bodies' coordinate systems.

This section explains how to visualize your pendulum with either tool, using either body representation. You can view the pendulum before you start and, separately, choose to animate it during simulation as well:

Starting Visualization

The first step is to open the Mechanical Environment Settings dialog box from your model window:

  1. On the Simulink menu bar, open the Simulation menu and open the Mechanical environment entry. The Mechanical Environment Settings dialog box appears. In the lower half, click the Visualization tab at the right.
  2. To view the pendulum in its static initial condition, select the Draw machine in initial state check box.
  1. To animate the pendulum visualization while the simulation is running, select the Animate machine during simulation check box as well.

  1. Leave the dialog open until the end of this section, as you will need to configure additional settings.


  Adding Sensors and Starting the Simulation Representing the Bodies