GUI callback doesn't seem to execute line by line

2 visualizaciones (últimos 30 días)
Henry
Henry el 24 de Jul. de 2014
Respondida: Henry el 24 de Jul. de 2014
Hi,
I'm having a problem in my GUIDE GUI when executing a pushbutton callback. The pushbutton runs an .m file which then runs a simulation, see the code below: (Peak_Value_Seek_2_3 runs the sim)
1- set(hObject,'BackgroundColor','yellow');
2
3- try
4- Peak_Value_Seek_2_3;
5- catch
6- error=lasterror;
7- error.message
8- errordlg(error.message,'Error');
9- set(hObject,'BackgroundColor','red')
10- return
11- end
12
13- set(hObject,'BackgroundColor','green')
So that the button itself turns yellow while the simulation is being run, and then turns green when the simulation is completed.
For some reason the button doesn't change colour to yellow until after the simulation has finished, and then almost immediately turns to green.
Having run it in debugger mode, with breaks at lines 1 and 4 it works as you would expect.
I have the same code in another (larger) GUI, and it works well in that - and even works ok for another pushbutton in the same GUI as the problem occurs (although the simulation this runs is much shorter than in the one with the problem).
I'm just confused as to why the problem is occurring?
Thanks in advance for your help
Henry

Respuesta aceptada

Henry
Henry el 24 de Jul. de 2014
this has been answered:
solution is to add
drawnow('expose')
at line 2 in the code.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by