| Contents | Index |
Typically, animations are triggered by passing an equation of the form
in the definition of an object.
This is equivalent to passing the attributes ParameterName = a,
, and
in the definition of the object.
The attribute
is equivalent to setting both
and
.
|
Attribute |
Type |
Value |
See Also:
Frames, TimeBegin, TimeEnd, TimeRange, VisibleAfter, VisibleAfterEnd, VisibleBefore, VisibleBeforeBegin, VisibleFromTo
See Also:
See the section Graphics and Animations in this document. In particular, see the section The Number of Frames and the Time Range for details.
Details:
Animations are defined object by object, not frame by frame.
In most cases, the user will define animations by passing an equation of the form
in the definition of an object. Any equation of this form that is not essential for the definition of a static version of the object is interpreted as an animation parameter and an animation range.
Passing such an equation is equivalent to setting the three attributes
ParameterName = a,
,
.
The attribute
serves as a short cut for setting both
and
.
The values
and
are the parameter values at the beginning and the end of the real time range in which an object is animated. This time range is set by the attributes TimeBegin and TimeEnd, respectively.
The parameter range
is mapped linearly to this time interval.
The name of the animation parameter may be an identifier or an indexed identifier. This parameter is a `global variable' that may be present in other quantities or attributes defining the object.
The definition of an object may involve procedures rather than symbolic expressions. E.g., a 2D function plot may be defined by
, where
is a procedure accepting one numerical argument
from the plot range between
und
.
In an animated version
, the function
will be called with two arguments
and
. Thus,
may be defined as a function accepting two parameters
or as a function with one parameter
, using the animation parameter
as a global variable.
Each animated object has its own animation parameter and range
. It is not necessary that several animated objects in a scene use the same parameter name. It is not used to synchronize the animations.
The synchronization is determined uniquely by the linear correspondence between the animation range
and the real time span of the animation set by the attributes TimeBegin and TimeEnd of the object.
Example 1
The definition of a static 2D function plot involves the specification of one range (for the
variable):
plot(plot::Function2d(sin(x), x = 0 .. 2*PI))

When a “surplus equation”
is passed, this is interpreted as a call to animate the function. The animation parameter may turn up in the expression defining the function:
plot(plot::Function2d(sin(x + a), x = a .. 2*PI, a = 0..PI))


A static function plot in 3D requires two ranges (for the
and the
variable):
plot(plot::Function3d(sin(x)*sin(y), x = 0 .. PI, y = 0..PI))

Now, a third equation
triggers an animation:
plot(plot::Function3d(sin(x + a)*sin(y - a), x = 0 .. PI,
y = 0..PI, a = 0..PI))


Example 2
We define an animated 2D function plot:
f := plot::Function2d(x^3 + a*x, x = -1..1, a = 0..2):
plot(f):


We swap the role of the independent variable
and the animation parameter
:
[f::XName, f::ParameterName] := [f::ParameterName, f::XName]:
[f::XRange, f::ParameterRange] :=
[f::ParameterRange, f::XRange]:
The function now is drawn as a function of
for various values of the “time”
:
plot(f)


delete f:
Example 3
We demonstrate the use of procedures in the definition of animated functions.
We wish to plot the eigenvalues of a matrix that depends on two parameters
and
. The eigenvalues are computed numerically in the procedure eigenvals. This procedure uses option remember, because it is called thrice with the same arguments by the procedures f1, f2, f3 that produce the smallest, the middle, and the largest eigenvalue, respectively, as functions of the parameters
and
:
eigenvals :=
proc(x, a)
option remember;
local A;
begin
A:= matrix([[1, a, x ],
[a, 2, a*x],
[x, a*x, 3 ]]):
sort(numeric::eigenvalues(A)):
end_proc:
f1:= (x, a) -> eigenvals(x, a)[1]:
f2:= (x, a) -> eigenvals(x, a)[2]:
f3:= (x, a) -> eigenvals(x, a)[3]:
plot(plot::Function2d(f1, x = -2..2, a = 0..2,
Color = RGB::Red),
plot::Function2d(f2, x = -2..2, a = 0..2,
Color = RGB::Green),
plot::Function2d(f3, x = -2..2, a = 0..2,
Color = RGB::Blue)):


delete eigenvals, f1, f2, f3:

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |