小编Nic*_*ick的帖子

在MATLAB GUI中打破for循环

for在MATLAB的GUI的打开功能中有一个循环,我正在尝试使用回调按钮来打破循环.我是MATLAB的新手.这是我的代码:

%In the opening function of the GUI
handles.stop_now = 0;
for i=1:inf
   if handles.stop_now==1
      break;
   end
end


% Executes on button press 
function pushbutton_Callback(hObject, eventdata, handles)
% hObject    handle to end_segmenting_button (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.stop_now=1;
guidata(hObject, handles);
Run Code Online (Sandbox Code Playgroud)

出于某种原因,尽管使用句柄定义变量,但按下按钮时循环不会中断.有谁知道发生了什么?谢谢.

matlab user-interface

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

matlab ×1

user-interface ×1