Documentation

smwritevideo

Configure and create multibody animation videos

Syntax

smwritevideo(modelIdentifier,videoName)
smwritevideo(modelIdentifier,videoName,Name,Value)

Description

example

smwritevideo(modelIdentifier,videoName) creates an animated video from the visualization results of a multibody simulation. modelIdentifier is the source model name or handle. videoName is the generated video file name and path. You can open the video file with any compatible media player.

The video properties are those specified in the Video Creator interface the moment you run the function. If the Video Creator parameters are in their default settings, the video properties are set to those defaults.

Before running smwritevideo, you must simulate the model. In addition, the model visualization results must open in a Mechanics Explorer window. If you have previously disabled model visualization, reenable it before continuing. To do this, see Enable Mechanics Explorer.

If the model visualization pane is split into tiles, the function captures only the active tile. A colored outline identifies the active tile. Select the desired tile before creating a video.

example

smwritevideo(modelIdentifier,videoName,Name,Value) adds options for specifying the video properties. Use the Name,Value pair arguments to change the video file format, frame refresh rate, frame width and height, and playback speed ratio. Unused arguments are set to the latest settings specified in the Video Creator tool.

Examples

collapse all

Create a video named flapping_wing_video from the simulation results of the sm_cam_flapping_wing featured example. Use the video settings currently specified in the Video Creator tool.

  1. Open the flapping wing featured example.

    sm_cam_flapping_wing

  2. Simulate the model.

    sim('sm_cam_flapping_wing')
  3. Create a video of the simulation results.

    smwritevideo('sm_cam_flapping_wing','flapping_wing_video');
    The function saves the video as flapping_wing_video in the current MATLAB® folder. The video file format is that specified in the Video Creator tool. Open the video using your media player of choice.

Create a video named wishbone_suspension_video from the simulation results of the sm_double_wishbone_suspension featured example. Change the video settings as shown in the table.

PropertyArgumentSetting
Playback Speed RatioPlaybackSpeedRatio2.0
Frame Rate (FPS)FrameRate60
Video FormatVideoFormatuncompressed avi

  1. Open the wishbone suspension featured example.

    sm_double_wishbone_suspension

  2. Simulate the model.

    sim(s'm_double_wishbone_suspension')
  3. Create a video of the simulation results.

    smwritevideo('sm_double_wishbone_suspension', 'wishbone_suspension_video',...
    'PlaybackSpeedRatio', 2.0, 'FrameRate', 60, 'VideoFormat', 'uncompressed avi');
    The function saves the video as wishbone_suspension_video.avi in the current MATLAB folder. Open the video using your media player of choice. The video plays at twice the original speed seen in Mechanics Explorer.

Input Arguments

collapse all

Name or handle of the source model, specified as a MATLAB string. You must simulate the specified model before using this function. The model visualization window must be open in order for the function to create a video.

Example: ‘sm_cam_flapping_wing’

Data Types: string

Name and full or relative path of the video file, specified as a string. In the absence of a file path, the function saves the video file in the current MATLAB folder. The file format is determined from the video settings specified using the Video Creator tool or the VideoFormat Name,Value pair argument.

Example: ‘flapping_wing_video’

Data Types: string

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'PlaybackSpeedRatio', 2.0

collapse all

Video playback speed relative to real time, specified as a positive scalar. Increase this factor for faster playback speeds. For example, a value of 2.0 doubles the video playback speed relative to the base playback speed used in Mechanics Explorer.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Number of video frames per second of playback time, specified as a positive scalar. Increase this factor for smoother playback but larger video files. Small numbers may lead to choppy videos.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

File format to save the video in, specified as a string. Select from a list of compressed and uncompressed formats with varying quality levels and storage space requirements. Use the default format of uncompressed jpeg avi if file size is a concern. Use uncompressed avi if top video quality is a priority. The mpeg-4 format is not supported in Linux systems.

Data Types: string

Width (W) and height (H) of the video contents, specified in pixel units as the two-element row vector [W H]. The vector elements must be positive integers. Use the default setting of auto to obtain the video dimensions from the Mechanics Explorer visualization pane size.

Example: [800 800]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Introduced in R2016b

Was this topic helpful?