Create a moving circle animation object and a timer animation object. Return the generated animation frames in reverse order.
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.
Create a 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 x-axis and y-axis to be equal length.
Next, use the text function to add a piece of text to count the elapsed time. Use num2str to convert the time parameter to a string.
By default, fanimator creates stop-motion frames with 10 frames per unit time within the range of t from 0 to 10. The default animation object contains a total of 101 frames. Use the command playAnimation to play the animation.
Next, return a structure array of frames from the animation in figure fig by using animationToFrame. Return the animation frames in reverse order by setting the 'Backwards' option to true. Set the frame rate per unit time to 2 to return a total of 21 frames.
frames=1×21 struct array with fields:
cdata
colormap
The structure frames contains two fields. The cdata field stores the image data as an array of uint8 values.
Reconstruct the animation frames by using the imshow function. For example, display the first frame and the 11th frame of the animation in a new figure window.