Could someone show me how to proceed with this code?

1 次查看(过去 30 天)
I've written the function playTrajectory() and attached my code to this message. I'm having trouble with the optional input arguments, and then plot the output to create animations and videos. Can someone send me in the right direction please? The instructions are shown below. Thank you very much.
Part 3a: Write a function called playTrajectory(), which takes an initial velocity and initial angle as input arguments. It should also take two optional arguments. The first should be set to True if you want the animation to show all points in the trajectory. False means show one point at a time. The second optional argument is the name of the file to use when saving the video. If no filename is specified, do not save a video file. playTrajectory() should use plot() to plot points in the trajectory to the figure.
The animation should play from t = 0 to t = timeflight(v0, angle), the time at which the objects hits the ground. In addition, make sure the trajectory is not drawn off screen by setting the x and y axes based on the peak height and range of the trajectory (hint: use the axes command).
Hint: Use getframe() to capture each frame of the animation (as shown here: http://goo.gl/WmxwQW). Once captured, use movie2avi to save the movie to an avi video file.
Part 3b: Write a script angrydots.m that runs until the user types CTRL-C (CMD-C on Mac). It should ask the user for an initial velocity, and an initial angle, and then call playTrajectory() to generate the corresponding animation. When done with the animation, angrydots.m should again ask the user for an initial velocity and angle.

回答(1 个)

Image Analyst
Image Analyst 2015-2-23
Attached is a demo for how to create a movie from a figure that is changing. One snapshot of the figure goes to one frame of video.

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by