Hello,
I'am working in gui Matlab. I created two gui.fig. One is used for the data Input, start and Reset button. The other is used to dispaly the result of simulation. I would like to reset the axes of results in the second gui.fig from the button reset in the first gui.fig.
I try this line of code in the callback of th push button reset but i dosen't work.
% handles2 = getappdata(GUI2);
%cla(handles2,handles.axes_GUI2,'reset');
Any help please

답변 (1개)

Voss
Voss 2022년 7월 8일

0 개 추천

Here is a working example, where clicking the pushbutton in the first figure clears the axes in the second figure.
The figures, uicontrol, and axes are created programmatically here, as opposed to in GUIDE (which looks like what you are doing). Nevertheless, you can run this example, see how it works, and try to apply the same logic to your code. If you get stuck, share your complete code (and .fig files if using GUIDE).
% first figure, with a pushbutton
handles1.GUI = figure();
handles1.pushbutton = uicontrol(handles1.GUI,'String','Reset','Callback',@reset_axes);
% second figure, with an axes
handles2.GUI = figure();
handles2.axes = axes();
% plot something in the axes so you can see when it resets
plot(handles2.axes,1:10);
% store the handle of the second figure in handles1,
% so that it can be accessed in the pushbutton Callback
handles1.GUI2 = handles2.GUI;
% store each handles structure in its figure
guidata(handles1.GUI,handles1);
guidata(handles2.GUI,handles2);
% pushbutton Callback
function reset_axes(src,evt)
% get the handles structure of the first figure,
% which contains the pushbutton (src)
handles1 = guidata(src);
% get the handles structure of the second figure,
% which contains the axes
handles2 = guidata(handles1.GUI2);
% clear the axes in the second figure
cla(handles2.axes,'reset');
end

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품

릴리스

R2020a

태그

질문:

2022년 7월 6일

답변:

2022년 7월 8일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by