Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
Veronica yep
Veronica yep le 7 Juil 2017
Clôturé : MATLAB Answer Bot le 20 Août 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 commentaires
Veronica yep
Veronica yep le 7 Juil 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 le 8 Juil 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.

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by