user2369001
user2369001

Reputation: 11

How can I refresh input data and update plot in MATLAB GUI?

I am working with Matlab GUI. My problem is the plots are not updated when I change the input data. My code is long but here is the plotting function I am using:

axes(handles.Diagram1)
hold all
for i=1:6:numel(t)
    plot(rn,E(i,:)/1000000)  
end
set(axesHandle,'Diagram1','Diagram1');

The tag of the axis plot is "Diagram1!

How can I fix this?

Upvotes: 0

Views: 4063

Answers (3)

Oliver Amundsen
Oliver Amundsen

Reputation: 1511

You can create a "clean figure" button, that 1) clears current axis (cla), 2) removes the legend, 3) clears the title, and sets any counter to 1. The figure is still there, but its contents are gone. Or you just include the code inside an "if":

function cleanbutton_Callback(source,eventdata)
 cla
 legend off
 title ''
 counter = 1;
end

Is this what you need?

Upvotes: 0

Sam Roberts
Sam Roberts

Reputation: 24127

MATLAB plots are not permanently linked to the data they display, so if you change the data after plotting, the plot will not be automatically updated. You would need to update the plot yourself after changing the data by reexecuting the plot command.

Upvotes: 1

Oszkar
Oszkar

Reputation: 697

I've never used it myself, but you're might looking for the drawnow function - see documentation here

Upvotes: 0

Related Questions