MATLAB Answers

How to add a marker on a plot which will move according to a for loop in MATLAB GUIDE GUI?

6 views (last 30 days)
Batuhan Yetisener
Batuhan Yetisener on 3 Nov 2017
Hello, I have been trying to add a marker to my plot but I have failed so far. This is the piece of code I am working on:
v = evalin('base','a matrix in my workspace which is 1000 by 1');
plot(v, 'Parent', handles.axes2);
for frames = 2:handles.frameCount-1
set(handles.text3, 'String', num2str(frames));
hold on;
plot(frames, v(frames), '.r');
I have two axes in my gui. axes1 is used to display a video and has no problems. "v" is plotted in axes 2 before the video display and I would like to add a marker to it which will "move" according to which frame the for loop is at.
The last plot(frames, v(frames)... line works but plots points on axes2.
I have 2 options:
1. Somehow delete the last marker plot when the loop moves to the next iteration. Actually I don't want to prefer this because I will implement a slider to control that marker in the future.
2. Any easier way to create a marker on a plot without plotting it over again :)
Thank you very much from now on...


Sign in to comment.

Answers (0)

Sign in to answer this question.