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.
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!