Environmental Engineering Reference
In-Depth Information
6.6 MATLAB ® Animations
One can use MATLAB
to produce animations. Using the getframe command,
single shots from a MATLAB
®
figure window can be gathered as one animation.
After finishing the production, there are commands to store and play the animations.
We demonstrate the procedure, how an animation is produced, for the transport
models that were described in Chaps. 4-6. The change of the concentration profile
with time is to be illustrated by a sequence of profiles. It is assumed that the results
of the simulation are stored on the matrix c , which contains concentration profiles in
the rows; the different rows represent different time instants. The entire sequence is
shown below and is included in the M-files 'simpletrans.m' , 'analtrans.m' and
'pdepetrans.m' (with minor differences concerning dtout ). The switch variable
ganim in the input specification is introduced to initiate or not initiate the animation
production.
®
The first command in the if -block concerns the filename under which the
animation is to be stored. Following the uiputle command, 7 the user is asked to
input the name of a 'mpg'-file. Thereafter the figure editor is opened. Within the
for -loop two concentration profiles are plotted in the figure window. The axes are
set to manual scaling, because otherwise the concentration interval, shown on the
vertical axis, may change from one frame to the other. For an animation such
a change is not wanted. Within each run through the loop, the current profile is
plotted in red color first by the first plot command. The YLim command ensures
that the concentration axis remains fixed between initial concentration and inflow
concentration. With the legend statement the current time becomes visible in
the figure.
The getframe stores the current figure in an animation structure, which in the
sample M-file in this implementation has the name Anim . The index j denotes the
index of the plot. After that assignment the same plot is performed in blue color,
7 With the uiputle command a file name is specified using a file-select box.
Search WWH ::




Custom Search