0

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?

HebeleHododo
  • 3,620
  • 1
  • 29
  • 38
user2369001
  • 11
  • 1
  • 1

3 Answers3

1

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.

Sam Roberts
  • 23,951
  • 1
  • 40
  • 64
0

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

Oszkar
  • 687
  • 1
  • 5
  • 20
0

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?

Oliver Amundsen
  • 1,491
  • 2
  • 21
  • 40