Create a Model Animation Video

UI and Command-Line Tools

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.

Create a Video Using smwritevideo

  1. Simulate the model to record.

    For video-capture scripts, consider running the simulation using the sim command.

  2. Programmatically define the video parameters deviating from the current Video Creator settings. E.g.,

    fps = 60; speedRatio = 2;
    Unspecified video parameters are set to the current values stored in the Video Creator UI.

  3. Call the smwritevideo function with the video parameters as function arguments.

    The smwritevideo function creates a model animation video and saves it with the specified name in the current MATLAB® folder.

Was this topic helpful?