%% Record Animation Object Simulation
% Simulate and record flight data. Create an animation object.

h = Aero.Animation;

%
% Control the frame display rate.

h.FramesPerSecond = 10;

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

h.TimeScaling = 5;

% The combination of 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 = 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.

h.play();

% Verify that a file named astMotion_JPEG.avi was created in the current folder.
%
% Disable recording to preserve the file.

h.VideoRecord = 'off';

% Copyright 2012 The MathWorks, Inc.