Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
Veronica yep
Veronica yep am 7 Jul. 2017
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentare
Veronica yep
Veronica yep am 7 Jul. 2017
I found the solution by removing ''run'' since Untitled2 and the function are in the same path, we don't need run.
Jan
Jan am 8 Jul. 2017
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.

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by