简体   繁体   中英

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?

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.

我从未drawnow使用过它,但是您可能正在寻找drawnow函数-请参阅此处的文档

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM