底下一個範例程式,用GUIDE實現的,只有兩個按鈕,Tag各位自己看得出來。真正加入的程式碼不多,全部元件使用預設性質即可。

function varargout = Test_Interrupt_guidata(varargin)

% TEST_INTERRUPT_GUIDATA M-file for Test_Interrupt_guidata.fig

%      TEST_INTERRUPT_GUIDATA, by itself, creates a new TEST_INTERRUPT_GUIDATA or raises the existing

%      singleton*.

%

%      H = TEST_INTERRUPT_GUIDATA returns the handle to a new TEST_INTERRUPT_GUIDATA or the handle to

%      the existing singleton*.

%

%      TEST_INTERRUPT_GUIDATA('CALLBACK',hObject,eventData,handles,...) calls the local

%      function named CALLBACK in TEST_INTERRUPT_GUIDATA.M with the given input arguments.

%

%      TEST_INTERRUPT_GUIDATA('Property','Value',...) creates a new TEST_INTERRUPT_GUIDATA or raises the

%      existing singleton*.  Starting from the left, property value pairs are

%      applied to the GUI before Test_Interrupt_guidata_OpeningFcn gets called.  An

%      unrecognized property name or invalid value makes property application

%      stop.  All inputs are passed to Test_Interrupt_guidata_OpeningFcn via varargin.

%

%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one

%      instance to run (singleton)".

%

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Test_Interrupt_guidata

% Last Modified by GUIDE v2.5 24-May-2009 10:49:57

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name',       mfilename, ...

'gui_Singleton',  gui_Singleton, ...

'gui_OpeningFcn', @Test_Interrupt_guidata_OpeningFcn, ...

'gui_OutputFcn',  @Test_Interrupt_guidata_OutputFcn, ...

'gui_LayoutFcn',  [] , ...

'gui_Callback',   []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before Test_Interrupt_guidata is made visible.

function Test_Interrupt_guidata_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn.

% hObject    handle to figure

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% varargin   command line arguments to Test_Interrupt_guidata (see VARARGIN)

global stopbit;  %只增加了stopbit的兩行

stopbit=1;

% Choose default command line output for Test_Interrupt_guidata

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes Test_Interrupt_guidata wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = Test_Interrupt_guidata_OutputFcn(hObject, eventdata, handles)

% varargout  cell array for returning output args (see VARARGOUT);

% hObject    handle to figure

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure

varargout{1} = handles.output;

% --- Executes on button press in pb_while.

function pb_while_Callback(hObject, eventdata, handles)

% hObject    handle to pb_while (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

%第一個按鈕按下之後,一直跑一個while loop,直到stopbit被另一個按鈕改變

global stopbit;

countN=1;

while stopbit

disp(['Showing while loop, Count=' int2str(countN)]);

countN=countN+1;

pause(0.1);

end

disp('while loop interrupted by other callback function.');

disp('Reset stopbit =1');

stopbit=1;

%第二個按鈕的程序

% --- Executes on button press in pb_stop.

function pb_stop_Callback(hObject, eventdata, handles)

% hObject    handle to pb_stop (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

global stopbit;

stopbit=0;

我試過用guidata更新handles的方式,沒用。我猜進入while loop後,handles已經被載入堆疊,在第一個按鈕的程序結束之前,它應該是看不到handles在外面被改過了。

matlab gui中断程序,MATLAB GUI的中斷程序相关推荐

  1. 怎么让程序后台运行_CPU中的程序是怎么运行起来的?

    1CPU的硬件最小原子 计算机从上世纪四十年代发展到现在有八十多年了,我们现在开发应用以及很少会涉及到底层的部分,硬件设计的电子专业在学校里面会学习模电数电这两门课,今天的第一部分就从这里说起. 一般 ...

  2. 在JAVA中 以下程序_在Java中,以下程序的输出结果是()_学小易找答案

    [单选题]运行以下Java代码,说法正确的是( ). [单选题]在Java中,以下程序的输出结果是() [单选题]利用"出声"的方式向学生展示教师分析问题的过程与方法的教学方法是_ ...

  3. 去除程序名称 去除程序属性详细信息中的程序名称 创建时间等信息

    文件右键属性 想去掉下图中的信息 开始操作 再次查看发现已经删除掉了 程序名称 教程至此结束

  4. 计算机运行命令如何关闭应用程序,如何禁止电脑中某些程序的运行

    windows并没有一个简单的软件,能禁止那些不想让别人使用的程序,但是它本身有这个功能的,要做到也不难.那就是启用"不要运行指定的Windows应用程序"策略 .在组策略中有一条 ...

  5. aistarter助手程序未运行_出现aistarter助手程序不在执行状态中

    1.金锄头文库是"C2C"交易模式,即卖家上传的文档直接由买家下载,本站只是中间服务平台,本站所有文档下载所得的收益全部归上传人(卖家)所有,作为网络服务商,若您的权利被侵害请及时 ...

  6. 【嵌入式基础小知识】详解单片机中的程序和变量是如何分布的以及一些注意事项

    "我固然不是了不起的跑步者,而是处于极为平凡的--毋宁说是凡庸的--水准.然而这个问题根本不重要.我超越了昨天的自己,哪怕只是那么一丁点儿,才更为重要.在长跑中,如果说有什么必须战胜的对手, ...

  7. 水击计算的matlab程序,MATLAB GUI在油库管道水击压力计算中的应用

    MATLAB GUI在油库管道水击压力计算中的应用 于聪聪 [浙江海洋学院石油化工学院 浙江舟山 316000] 收稿日期:2010 - 08 - 11.作者简介:于聪聪(1989 - ) ,女 ,本 ...

  8. matlab波的极化特性,Matlab GUI在电磁波极化特性教学中的应用

    科技创新导报 2018 NO.16Science and Technology Innovation Herald 创新教育 科技创新导报 Science and Technology Innovat ...

  9. Matlab GUI学习02:使用GUIDE开发图形界面程序

    pdf版本笔记的下载地址: Matlab GUI学习02_使用GUIDE开发图形界面程序(访问密码:3834) Matlab GUI学习02:使用GUIDE开发图形界面程序 GUIDE GUIDE简介 ...

  10. matlab 获取edit,关于matlab的gui中获取edit值的问题

    本帖最后由 李昊波 于 2017-7-16 11:12 编辑 想请教一个问题,制作了一个有24个edit的gui程式,想获取edit中的数值然后用这些数值来做排列组合,但是运行结果显示为生成了一个空的 ...

最新文章

  1. 洛谷P4768 [NOI2018]归程(Kruskal重构树)
  2. LINUX常用命令(基础)
  3. LeetCode - Longest Common Prefix
  4. 【Android 逆向】ELF 文件格式 ( ELF 文件头 | ELF 文件头标志 | ELF 文件位数 | ELF 文件大小端格式 )
  5. TableCellRenderer TableCellEditor(三)
  6. 160 - 41 defiler.1.exe
  7. java用接口实例化对象_[求助]迷茫中,接口可以直接实例化对象吗?
  8. 判断 iframe 是否加载完成的完美方法(转)
  9. 2020年Java实训项目【GUI学生信息管理系统】目录
  10. 设置Cookie请求头报错(Refused to set unsafe header “Cookie“)
  11. MySQL error writing file 错误
  12. c语言编写的程序不具备移植性,《C语言》试卷1
  13. Sublime Text 2 常用插件介绍
  14. pythonjam怎么使用_jam怎么用啊多多举例子啊各种词意的用法
  15. win10或11非华为电脑安装最新的电脑管家(支持移动应用引擎)安装方法及问题解决
  16. 汇编语言怎么编译python_汇编语言编译器的编写方法
  17. word转html制作操作手册,Word文档转换为HTML帮助文档操作手册范本.pdf
  18. express 验证码功能
  19. cf英文名字格式好看的_格式好看的cf英语名字【三篇】
  20. Java中常用的String方法解析和使用示例

热门文章

  1. 你知道Thread线程是如何运作的吗?
  2. matlab模拟频谱仪,program 本实验要求基于声卡与MATLAB实现音频信号频谱分析仪的设计 联合开发网 - pudn.com...
  3. java校园门禁刷脸系统,学校人脸识别门禁系统打造智慧校园
  4. wps里为什么没有华文楷体_是谁动了我的字体?为什么Word或PPT换台电脑打开字体就变了呢?...
  5. 震网三代(CVE-2017-8464)
  6. 设置网页title旁边的小图标详解
  7. 驰为 hi12 linux,驰为Hi12 最适合入手的手写平板 真的可以试试
  8. 重绘panel控件,实现panel的阴影效果
  9. C# 使用Panel控件实现窗体嵌套
  10. 【网络存储】存储区域网络SAN