如何在MatLab中并行运行两个GUI? [英] How do I run two GUIs in MatLab in parallel?

查看:778
本文介绍了如何在MatLab中并行运行两个GUI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MatLab,并且有两个GUI.当我单击一个GUI中的按钮时,将调用第二个GUI,并且两个GUI都可以并行工作.如果有人知道该问题的答案,请给我答复.

I am using MatLab and I have two GUIs. When I click on a push button in one GUI, the second GUI will invoke, and both GUIs both can work in parallel. If any body knows answer to this question please give reply to me.

我有两种GUI形式.在第一个示例中,我将旋转一条直线(使用极函数).这是出于雷达仿真的目的.在该GUI中,我有一个按钮.当我按下它的行时(通过使用for循环和暂停功能.实际上这是一个模拟,看起来像是在圆周上旋转)

I have two GUI forms. In the first one I am rotating a line in a circle (by using the polar function. This is for my radar simulation purpose). In that GUI I have one push button. When I press it line (by using the for loop and pause function. Actually it's a simulation, kind of looks like a rotate in the circle)

圆圈旋转,直到我在同一GUI中按下另一个按钮.我还有一个按钮.如果按此键,它将激活另一个GUI,但该GUI进行相同的旋转,但不旋转整个圆(圆的某个部分)(扇形).因此,在这里我需要圆和扇形旋转中的直线.但是实际上,当我从圆形GUI的按钮调用扇形GUI(第二个GUI)时,会发生以下情况:线在圆弧停点处旋转,并且在扇形旋转完成后将控制权交给扇形.圆圈出现在扇区GUI中.

The circle rotates until I press another pushbutton in the same GUI. I have one more push button. If I press this, it activates another GUI doing the same rotation but not the full circle, some part of the circle (sector). So here I need line in both circle and sector rotation. But actually what happens when I call the sector GUI (2nd GUI) from the circle GUI's pushbutton is that the line rotates in circle stops and control gives to sector after completion of the sector rotation. Circle is appearing in sector GUI.

如果有人知道如何并行执行这两个GUI,请回答我.如果仍然不太清楚,请告诉我,我会再解释一些.

If anybody knows how to execute these two GUIs in parallel, please answer me. If this is still too vague, please tell me and I will explain some more.

我的代码如下:

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

有人可以建议我如何连续更改颜色并以两个数字连续旋转极性函数中的线吗?

Can anyone suggest me how to change the color continuously and rotate the line in polar function continuously in two figures?

推荐答案

我制作了一个视频,介绍了如何使两个或多个GUI共享数据并一起工作.简短的答案是使用SETAPPDATA和GETAPPDATA在GUI之间共享数据.长答案在这里:

I made a video that covers how to make two or more GUIs share data and work together. The short answer is use SETAPPDATA and GETAPPDATA to share data between GUI's. The long answer is here:

http://blogs.mathworks. com/videos/2005/10/03/guide-video-part-two/

我的GUI视频收藏可以在这里找到

My collection of GUI videos can be found here:

http://blogs.mathworks.com/videos/category/gui-or-guide/

-道格

这篇关于如何在MatLab中并行运行两个GUI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆