opening multiple figures with a single gui
5 次查看(过去 30 天)
显示 更早的评论
hey, i want to make a GUI ,on starting it will show 3 push buttons, clicking on first push button opens a figure with some axes and some edit texts objects there. similarly on clicking the second figure. on clicking the third push button,a figure opens which uses the data entered on first and second figures. i am confused, how to do it, i want all the figures open at the same time. can any one please explain with a simple example.
0 个评论
回答(2 个)
Paulo Silva
2011-6-25
Too many questions and nothing done so far, here's a simple GUI that adds the value you put in the textbox of GUI1 with the one from GUI2, don't close GUI1 and GUI2, just minimize them, press the button GUI3 on the main GUI and you will see the sum on the textbox of the GUI3
function testmgui
figure
pbh1 = uicontrol(gcf,'Style','pushbutton','String','GUI 1',...
'Position',[10 60 60 40],...
'callback',@gui1);
pbh2 = uicontrol(gcf,'Style','pushbutton','String','GUI 2',...
'Position',[10 90 60 40],...
'callback',@gui2);
pbh3 = uicontrol(gcf,'Style','pushbutton','String','GUI 3',...
'Position',[10 120 60 40],...
'callback',@gui3);
function gui1(obj,event)
figure
txt1 = uicontrol(gcf,'Style','edit','String','1',...
'Position',[10 90 60 40]);
set(txt1,'Tag','txt1')
end
function gui2(obj,event)
figure
txt1 = uicontrol(gcf,'Style','edit','String','2',...
'Position',[10 90 60 40]);
set(txt1,'Tag','txt2')
end
function gui3(obj,event)
figure
txt3 = uicontrol(gcf,'Style','edit',...
'Position',[10 90 60 40]);
txt1=findall(0,'Tag','txt1');
txt2=findall(0,'Tag','txt2');
stxt1=get(txt1,'String')
stxt2=get(txt2,'String')
set(txt3,'String',num2str(str2num(stxt1)+str2num(stxt2)))
end
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!