我正在使用MatLab,我有两个GUI.当我在一个GUI中单击按钮时,第二个GUI将调用,并且两个GUI都可以并行工作.如果有任何机构知道这个问题的答案,请回复我.
我有两个GUI表单.在第一个中,我在一个圆圈中旋转一条线(使用极性函数.这是为了我的雷达模拟目的).在那个GUI中我有一个按钮.当我按下它时(通过使用for循环和暂停功能.实际上它是一个模拟,看起来像是在圆圈中旋转)
圆圈旋转,直到我在同一个GUI中按下另一个按钮.我还有一个按钮.如果按此按钮,它会激活另一个执行相同旋转的GUI,但不会激活整圆,圆圈的一部分(扇区).所以在这里我需要在圆圈和扇区旋转中都行.但实际上,当我从圆形GUI的按钮调用扇区GUI(第二个GUI)时,会发生这样的情况:线条以圆形停止旋转,控制在扇区旋转完成后给扇区.圆形出现在扇区GUI中.
如果有人知道如何并行执行这两个GUI,请回答我.如果这仍然太模糊,请告诉我,我会解释一些.
我的代码如下:
function twoguis
%Initializations:
hFigure2 = [];
hAxes2 = [];
%Make figure 1:
hFigure1 = figure('Position',[50 200 300 300]);
hAxes1 = axes('Parent',hFigure1,'Position',[0.1 0.2 0.8 0.7]);
hButton = uicontrol('Style','pushbutton',...
'Position',[10 10 100 20],...
'String','New Window',...
'Callback',@button);
% Start a loop that continuously changes the color of
% the axes at 1 second intervals:
while true, % You will have to press Ctrl-c to stop!
newColor = rand(1,3);
set(hAxes1,'Color',newColor);
if ishandle(hAxes2),
set(hAxes2,'Color',newColor);
end
drawnow;
pause(1);
end
function button(source,event)
% Check if Figure 2 has already been made:
if ishandle(hFigure2),
return;
end
% If it isn't made, make Figure 2:
hFigure2 = figure('Position',[350 200 300 300]);
hAxes2 = axes('Parent',hFigure2,'Position',[0.1 0.2 0.8 0.7]);
for xc=0:.05:6.28;
polar([0,xc],[0,10]);
pause(.1);
end
end
end
Run Code Online (Sandbox Code Playgroud)
任何人都可以建议我如何连续改变颜色并在两个数字中连续旋转极性函数线?
我制作了一个视频,介绍了如何让两个或多个GUI共享数据并协同工作.简短的回答是使用SETAPPDATA和GETAPPDATA在GUI之间共享数据.答案很长,在这里:
http://blogs.mathworks.com/videos/2005/10/03/guide-video-part-two/
我的GUI视频集可以在这里找到:
http://blogs.mathworks.com/videos/category/gui-or-guide/
-Doug