Main Content


Class: Aero.Animation
Namespace: Aero

Animate Aero.Animation object given position/angle time series




play(h) animates the loaded geometry in the animation object h for the current TimeseriesDataSource at the specified rate given by the Aero.Animation 'TimeScaling' property in seconds of animation data per second of wall-clock time. The animation is created at a certain number of frames per second using the 'FramesPerSecond' property. For more information on how the method uses timeseries data, see Algorithms.

Input Arguments

expand all

Aerospace animation object, specified as an Aero.Animation object.


expand all

Simulate and record flight data. Use the data to create an animation object.

h = Aero.Animation;

Control the frame display rate.

h.FramesPerSecond = 10;

Set the time-scaling property TimeScaling on the animation object to specify the data per second.

h.TimeScaling = 5;

The combination of the FramesPerSecond and TimeScaling properties determines the time step of the simulation. These settings result in a time step of approximately 0.5 s.

Create and load a body for the animation object.

idx1 = createBody(h,'','Ac3d');

Load simulated flight trajectory data, simdata.

load simdata;

Set the time series data for the body.

h.Bodies{1}.TimeSeriesSource = simdata;

Create a figure object for the animation object.



Set up recording properties.

h.VideoRecord = 'on';
h.VideoQuality = 50;
h.VideoCompression = 'Motion JPEG AVI'
h = 
  Animation with properties:

                      Name: ''
                    Figure: [1×1 Figure]
    FigureCustomizationFcn: []
                    Bodies: {[1×1 Aero.Body]}
                    Camera: [1×1 Aero.Camera]
                  TCurrent: 0
               VideoRecord: 'on'
             VideoFileName: 'temp'
          VideoCompression: 'Motion JPEG AVI'
              VideoQuality: 50
               VideoTStart: NaN
               VideoTFinal: NaN
               TimeScaling: 5
           FramesPerSecond: 10
                    TStart: NaN
                    TFinal: NaN

h.VideoFilename = 'astMotion_JPEG';

Play the animation.


Verify that a file named astMotion_JPEG.avi was created in the current folder.


Wait for the animation to stop playing before the modifying the object.


Disable recording to preserve the file.

h.VideoRecord = 'off';


The interprets its time series data according to the Aero.Body 'TimeSeriesSourceType' property, which can be one of these values.


MATLAB® time series data with six values per time:

x y z phi theta psi

x, y, and z are Cartesian position coordinates. phi, theta, and psi are roll, pitch, and yaw angles. The values are resampled.


Simulink.Timeseries (Simulink® signal logging):

  • First data item

    x y z

  • Second data item

    phi theta psi


Simulink struct with time, for example, Simulink root outport logging 'Structure with time':

  • signals(1).values: x y z

  • signals(2).values: phi theta psi

Signals are linearly interpolated vs. time using the interp1 function.

'Array6DoF'A double-precision array in n rows and seven columns for 6DOF data: time x y z phi theta psi. If a double-precision array of eight or more columns is in 'TimeSeriesSource', the first seven columns are used as 6DOF data.
'Array3DoF'A double-precision array in n rows and four columns for 3DOF data: time x z theta. If a double-precision array of five or more columns is in 'TimeSeriesSource', the first four columns are used as 3DOF data.
'Custom'Position and angle data is retrieved from 'TimeSeriesSource' by the currently registered 'TimeseriesReadFcn'.

The TStart and TFinal values have these limitations:

  • TStart and TFinal must be numeric.

  • TStart and TFinal cannot be Inf or NaN.

  • TFinal must be greater than or equal to TStart.

  • TFinal cannot be greater than the maximum Timeseries time.

  • TStart cannot be less than the minimum Timeseries time.

The method uses a time advancement algorithm based on animation frames counted by ticks:

ticks = ticks + 1;
time  = tstart + ticks*FramesPerSecond*TimeScaling;


TimeScalingSpecifies the seconds of animation data per second of wall-clock time.
FramesPerSecondSpecifies the number of frames per second used to animate the 'TimeSeriesSource'.

For default 'TimeseriesReadFcn' methods, the last frame played is the last time value.

Time is in seconds. Position values are in the same units as the geometry data loaded into the animation object. All angles are in radians.


If there is a 15% difference between the expected time advance and the actual time advance, this method generates this warning:

TimerPeriod has been set to <value>. You may wish to modify the animation 
TimeScaling and FramesPerSecond properties to compensate for the 
millisecond limit of the TimerPeriod.  See documentation for details.

Version History

Introduced in R2007a