Continual points on a movie

I have a movie made of a plot with images behind each frame and points that mark certain locations via plots. I want to have the points from previous frames showing on the current frame as if showing a "path" per se. I have made the movie using the imshow, hold on, plot(), and get frame functions in a for loop. What would be the best way to accomplish this? Thank you.

4 Comments

Geoff Hayes
Geoff Hayes on 21 Apr 2020
Edited: Geoff Hayes on 21 Apr 2020
Jake - can you show some of your code? Do you have a for loop that - on each iteration - creates a new figure (via imshow) to which you had a plot to? Do you want to all past calls to plot to be carried forward to the next iteration? (If so, then just maintain an array of this historical data to update (with new data) and plot on each iteration.)
q=1
for i=1:numimgs
imshow(I{i})
hold on
fishplot(i)=plot(x(i,:),y(i,:),'r.')
hold off
P(q)=getframe
q=q+1;
end
Here is my for loop. I would like all past points to be added to the current frame with the new data
If you want to write a movie use VideoWriter

Sign in to comment.

Answers (1)

If you want to plot all the points (x,y) from the first to point i you can do something like this:
q = 1;
for i1 = 1:numimgs % Avoid using i and j as indices, they are also used for (-1)^(1/2)
imshow(I{i1})
hold on
plot(x(1:i1),y(1:i1),'b.')
fishplot(i1) = plot(x(i1,:),y(i1,:),'r.')
hold off
P(q) = getframe;
q = q+1;
end
Maybe that is what you want to achieve.
HTH

Categories

Find more on Just for fun in Help Center and File Exchange

Asked:

on 21 Apr 2020

Answered:

on 21 Apr 2020

Community Treasure Hunt

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

Start Hunting!