필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to prevent looping while running a m file in GUI pushbutton

조회 수: 1 (최근 30일)
Veronica yep
Veronica yep 2017년 7월 7일
마감: MATLAB Answer Bot 2021년 8월 20일
I have a problem when I try use a push button in GUI to start running a file(for spectrum plotting, which means the data will keep changing). Is there any way to terminate the program without quitting Matlab (other than ctrl+c and dbquit-which is not going to work ) .Also I try to debug but seems like it always stuck at ''run Untitled2'' which causes a big problem that I couldn't quit from debugging. Even I click on quit debugging, it will run automatically go into a debug mode.
% --- Executes on button press in start.
function start_Callback(hObject, eventdata, handles)
figure(2)
run Untitled2 % this is where the looping happened
% --- Executes on key press with focus on start and none of its controls.
function start_KeyPressFcn(hObject, eventdata, handles)
start_Callback(hObject, eventdata, handles)
function stop_Callback(hObject, eventdata, handles)
global b
b = 1;
function stop_KeyPressFcn(hObject, eventdata, handles)
stop_Callback(hObject, eventdata, handles)
  댓글 수: 2
Veronica yep
Veronica yep 2017년 7월 7일
I found the solution by removing ''run'' since Untitled2 and the function are in the same path, we don't need run.
Jan
Jan 2017년 7월 8일
Note that globals are well known to provoke bugs and mistakes. If you use such trivial names as "b" as globals in several functions, confusing interferences are expected.
Better use setappdata, guidata or the UserData of a GUI element as a flag.

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by