Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force matlab gui to update ui control mid-function

Tags:

matlab

I'm working on a gui using GUIDE in MATLAB, and from what I've read it looks like MATLAB updates the UI controls based on a timer every so often. Is there a way to force it to update the UI controls, so I can make it update in the middle of the function? Right now I have a function that does, simplifed, something like

set(handles.lblStatus,'String','Processing...')
%function that takes a long time
set(handles.lblStatus,'String','Done')

Since MATLAB doesn't update the GUI during a Callback function, the user only ever sees 'Done' after a long period of waiting and never sees 'Processing'. I tried adding guidata(hObject, handles) after the first set, hoping it would force the screen to update, but it doesn't.

like image 301
Alex Zylman Avatar asked Aug 25 '10 18:08

Alex Zylman


1 Answers

Try calling DRAWNOW.

set(handles.lblStatus,'String','Processing...')
drawnow
%function that takes a long time
set(handles.lblStatus,'String','Done')
like image 193
Jonas Avatar answered Oct 30 '22 05:10

Jonas