Update figure window and execute pending callbacks
Use drawnow in animation loops to update the figure during function execution and to update graphical user interfaces.
drawnow update causes only user-interface objects to refresh. It does not allow pending callbacks to execute and does not refresh graphics objects.
Note: On Macintosh systems, drawnow update produces the same results as described for drawnow expose
Other actions and function calls that cause the MATLAB® software to flush the queue and update the figure include:
Returning to the MATLAB prompt
Executing the following functions:
Functions that wait for user input (i.e., waitforbuttonpress, waitfor, ginput)
Any code that causes one of the above functions to execute. For example, suppose h is the handle of an axes. Calling axes(h) causes its parent figure to be made the current figure and brought to the front of all displayed figures, which is the equivalent of executing a drawnow.
Using drawnow in a loop causes the display to update while the loop executes:
t = 0:pi/100:2*pi; y = exp(sin(t)); h = plot(t,y,'YDataSource','y'); for k = 1:0.01:10 y = exp(sin(t.*k)); refreshdata(h,'caller') drawnow end