MATLAB Answers

How can i update data in the figure window in MATLAB GUI using pushbutton callback?

4 views (last 30 days)
Vasishta Bhargava
Vasishta Bhargava on 23 Nov 2018
Edited: Vasishta Bhargava on 26 Nov 2018
I have MATLAB GUI, which plots data in figure using pushbutton callback
Even though the figure window is updating the data for every iteration inside the for loop, it is not able to hold and display the data from previous iteration of the for loop.
I have tried 'hold on' option but it does not work for the GUI case
How can i fix it.

  6 Comments

Show 3 older comments
Walter Roberson
Walter Roberson on 23 Nov 2018
guidata does not have anything to do with plots being erased . plots get erased if hold on is not in effect or if there is a cla or clf
Vasishta Bhargava
Vasishta Bhargava on 23 Nov 2018
there is no cla, clf in the loop, the code structure is shown below
for i = 1: N
...
for j = 1 :X
...
...
...
end
semilogx(...)
end

Sign in to comment.

Accepted Answer

Jan
Jan on 23 Nov 2018
Edited: Jan on 23 Nov 2018
Instead of hold on prefer to create the axes with the wanted "accumulation" flag directly:
axes('NextPlot', 'add')
Now new line objects created by plot() do not replace the existing contents, but are added. Do this before the loop.
Does this help already?

  1 Comment

Vasishta Bhargava
Vasishta Bhargava on 23 Nov 2018
okay, found the solution myself from mathworks help documentation,
use hold(ax,'on') after the plot i.e.
for i = 1: N
...
for j = 1 :X
...
...
...
end
semilogx(...)
hold(ax,'on')
end
and it works fine, Thanks anyway for the response

Sign in to comment.

More Answers (0)

Products


Translated by