CONNECT TWO gui.FIG IN GUI matlab

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

Answers (1)

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

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Release

R2020a

Tags

Asked:

on 6 Jul 2022

Answered:

on 8 Jul 2022

Community Treasure Hunt

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

Start Hunting!