rewindAnimation
Rewind previously played animation objects
Description
Examples
Rewind Animation of Moving Circle
Create an animation of a moving circle and rewind it using rewindAnimation
.
First, create two symbolic variables, t
and x
. The variable t
defines the time parameter of the animation. Use t
to set the center of the circle at (t,1)
and x
to parameterize the perimeter of the circle within the range [-pi pi]
. Create the circle animation object using fanimator
. Set the x-axis and y-axis to be equal length.
syms t x fanimator(@fplot,cos(x)+t,sin(x)+1,[-pi pi]) axis equal
Play the animation by entering the command playAnimation
. By default, playAnimation
plays the animation within the range of t
from 0 to 10. You can rewind the animation by using rewindAnimation
. rewindAnimation
restores the animation time parameter to its initial value at t = 0
and shows the starting animation frame.
rewindAnimation
Rewind Animation of Moving Circle with Timer
Create an animation of a moving circle with a timer, and rewind the animation using rewindAnimation
.
First, create two symbolic variables, t
and x
. The variable t
defines the time parameter of the animation. Create a figure window for the animation.
syms t x fig = figure;
Create the circle animation object using fanimator
. Use t
to set the center of the circle at (t,1)
and x
to parameterize the perimeter of the circle within the range [-pi pi]
. Set the range of the animation time parameter to [4 8]
. Set the x-axis and y-axis to be equal length.
fanimator(@fplot,cos(x)+t,sin(x)+1,[-pi pi],'AnimationRange',[4 8]) axis equal
Next, add a timer animation object. Use the text
function to create a piece of text to count the elapsed time. Use num2str
to convert the time parameter to a string.
hold on fanimator(@(t) text(8,3,"Timer: "+num2str(t,2)),'AnimationRange',[4 8]) hold off
Play the animation in figure fig
between 4 and 8 seconds by entering the playAnimation
command.
playAnimation(fig,'AnimationRange',[4 8])
You can rewind a previously played animation by using rewindAnimation
. rewindAnimation
restores the animation time parameter to its initial value at t = 4
and shows the starting animation frame.
rewindAnimation(fig)
Input Arguments
fig
— Target figure
Figure
object
Target figure, specified as a Figure
object. For more information
about Figure
objects, see figure
.
Version History
Introduced in R2019a
See Also
animationToFrame
| playAnimation
| fanimator
| writeAnimation
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)