Documentation

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.

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

Create a Video Using smwritevideo

  1. Simulate the model to record. E.g.,

    modelName = 'sm_dump_trailer';
    sim(modelName);
    Simscape™ Multibody™ software simulates the dump trailer featured example.

  2. 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.

  3. Define the desired name and path of the animation video.

    videoName = 'dump_trailer_animation'
    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.

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

    smwritevideo(modelName,videoName,...
    'PlaybackSpeedRatio',speedRatio,'FrameRate',fps);
    The smwritevideo function creates a video of the model animation and saves it with the name dump_trailer_animation in the current folder.

Was this topic helpful?