GUI callback doesn't seem to execute line by line

2 次查看(过去 30 天)
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

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by