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 to automate video capture following model simulation.
Before Creating a Video
Multibody Explorer must be set to open on model update. You can view and change the current setting in the Simscape Multibody > Explorer tab of the Model Configuration Parameters window.
The video viewpoint is always that of the active tile. The active tile is demarcated by a colored bounding box. 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
Simulate the model to record. Animations and the videos generated from them are based on your model simulation data.
In Multibody Explorer, in the Apps section, select Video Creator. Video Creator relies on your model visualization.
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.
Click the Create button. Video Creator generates a model animation video and saves it with the specified name in the specified folder.
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.
openExample('sm/CreateModelAnimationVideoExample') modelName = 'HydraulicInterface' sim(modelName)
Define any video parameters that deviate from your current Video Creator settings.
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.
smwritevideo(modelName,videoName,... 'PlaybackSpeedRatio',speedRatio,'FrameRate',fps)
The smwritevideo
function creates a video of the model animation and saves it with the name DumpTrailerAnimation
in the current folder.