Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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

1 visualización (últimos 30 días)
Veronica yep
Veronica yep el 7 de Jul. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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 comentarios
Veronica yep
Veronica yep el 7 de Jul. de 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 el 8 de Jul. de 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.

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by