%% Record Animation for Four Seconds
% Simulate flight data for four seconds. Create an animation object.

h = Aero.Animation;

%
% Control the frame display rate.

h.FramesPerSecond = 10;

%
% Configure the animation object to set the seconds of animation data per second time-scaling (TimeScaling) property.

h.TimeScaling = 5;

% The combination of FramesPerSecond and TimeScaling properties determines the time step of the simulation (TimeScaling/|FramesPerSecond|). These settings result in a time step of approximately 0.5 s.
%
% Create and load a body for the animation object.

idx1 = h.createBody('pa24-250_orange.ac','Ac3d');

%
% Load simulated flight trajectory data (simdata), located in matlabroot\toolbox\aero\astdemos.

load simdata;

%
% Set the time series data for the body.

h.Bodies{1}.TimeSeriesSource = simdata;

%
% Create a figure object for the animation object.

h.show();

%
% Set up recording properties.

h.VideoRecord='on';
h.VideoQuality = 50;
h.VideoCompression = 'Motion JPEG AVI';
h.VideoFilename = 'astMotion_JPEG';

%
% Play the animation from TFinal to TStart.

h.TSTart = 1;
h.TFinal = 5;
h.play();

% Verify that a file named astMotion_JPEG.avi was created in the current folder. When you rerun the recording, notice that the play time is shorter than that in the previous example when you record for the length of the simulation time.
%
% Disable recording to preserve the file.

h.VideoRecord = 'off';

% Copyright 2012 The MathWorks, Inc.