Number of frames in an animation

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Value Summary

InheritedPositive integer


Frames determines the number of frames in the animation of an object.

Frames = n with a positive integer n sets the number of frames for the animation of an object to n.

These frames are played during the real time period given by TimeBegin = t0 and TimeEnd = t1 (in seconds).

The resulting frame rate is n/(t1 - t0) (frames per second).

Increasing the number of frames does not mean that the animation lasts longer, because the renderer does not work with a fixed number of frames per second.

Keeping the play period from TimeBegin = t0 to TimeEnd = t1 fixed, an increased number of frames just produces a higher frame rate leading to a smoother animation.

Note that the human eye cannot distinguish between different frames if they change with a rate of more than 25 frames per second. Thus, the number of frames n for an animation should satisfy n < 25 (t1 - t0).

With the default time range TimeBegin = t0 = 0, TimeEnd = t1 = 10 (seconds), it does not make sense to specify Frames = n with n > 250. If a higher n is required to obtain a sufficient resolution of the animated object, one should increase the time for the animation by a sufficiently high value of TimeEnd.

Since the values of Frames, TimeBegin, TimeEnd may be set separately for different objects, it is possible to animate objects in a scene with different frame rates. Cf. Example 2.


Example 1

We set the number of frames for the following animation to 40. The default animation range of 10 seconds is used. This results in a frame rate of 4 frames per second:

plot(plot::Function2d(sin(a*x), x = -PI..PI, 
                      a = 1..2, Frames = 40)):

Example 2

Here is an example of different frame rates in one plot. The default animation range of 10 seconds is used.

The red point is sampled with 30 frames in 10 seconds, the blue one with 100 frames in 10 seconds. The animation of the blue point is much smoother:

plot(plot::Function2d(sin(x), x = 0..PI, 
                      Color = RGB::Black),
     plot::Point2d([a , sin(a) + 0.07], a = 0 .. PI, 
                   Color = RGB::Red, Frames = 30),
     plot::Point2d([a , sin(a) - 0.07], a = 0 .. PI,
                   Color = RGB::Blue, Frames = 100),
     PointSize = 4*unit::mm):