Main Content

Create a Model Animation Video

You can create a model animation video interactively, using the Video Creator tool, or programmatically, using the smwritevideo function. The tool and function provide equivalent ways to perform the same task. Use the tool to more intuitively configure and create a video. Use the function for your command-line workflows, e.g., to automate video capture following model simulation.

Before Creating a Video

  • Mechanics Explorer must be set to open on model update. You can view and change the current setting in the Simscape Multibody > Visualization tab of the Model Configuration Parameters window.

  • Only the active visualization tile in Mechanics Explorer is recorded. A visualization tile is a subdivision of the Mechanics Explorer visualization pane that shows a specific view of the model. The active tile is demarcated by a colored bounding box.

  • The video viewpoint is always that of the active tile. To change the model viewpoint in the recorded video, you must change the viewpoint of the active tile. Use a dynamic camera for a moving point or the global camera for a static viewpoint.

Create a Video Using Video Creator

  1. Simulate the model to record. Animations and the videos generated from them are based on your model simulation data.

  2. In Mechanics Explorer, select Tools > Video Creator. Video Creator relies on your model visualization and is accessible through Mechanics Explorer only.

  3. In Video Creator, specify the desired video parameters. Video parameters that you can modify include the video frame rate, frame size, playback speed ratio, and video file format.

  4. Click the Create button. Video Creator generates a model animation video and saves it with the specified name in the specified folder.

  5. Save the model animation video in a folder for which you have write privileges.

Create a Video Using smwritevideo

  • In this section, we use the dump trailer model as an example. Simulate the model to record.

modelName = 'HydraulicInterface'
  • Define any video parameters that deviate from your current Video Creator settings. E.g.,

fps = 60; speedRatio = 2;

All remaining video parameters are configured as specified in Video Creator.

  • Define the desired name and path of the animation

videoName = 'DumpTrailerAnimation'
  • In the absence of a path, the function saves the video in the current folder. You must have write privileges to the folder in order to save the video.

  • Call the smwritevideo function with the video name and parameters as function arguments.


The smwritevideo function creates a video of the model animation and saves it with the name DumpTrailerAnimation in the current folder.

Related Topics