| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
drawnow
drawnow expose
drawnow update
drawnow causes figure windows and their children to update, and flushes the system event queue. Any callbacks generated by incoming events (e.g., mouse or key events) are dispatched before drawnow returns.
drawnow expose causes only graphics objects to refresh, if needed. It does not allow callbacks to execute and does not process other events in the queue.
drawnow update causes only non graphics objects to refresh, if needed. It does not allow callbacks to execute and does not process other events in the queue.
You can combine the expose and update options to obtain both effects:
drawnow expose update
Other events that cause the MATLAB software to flush the event queue and draw the figure include:
Returning to the MATLAB prompt
Executing the following functions:
figure
getframe
input
keyboard
pause
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 results in the event queue being flushed.
Using drawnow in a loop causes the display to update while the loop executes:
t = 0:pi/20:2*pi; y = exp(sin(t)); h = plot(t,y,'YDataSource','y'); for k = 1:.1:10 y = exp(sin(t.*k)); refreshdata(h,'caller') % Evaluate y in the function workspace drawnow; pause(.1) end
snapnow, waitfor, waitforbuttonpress
![]() | dragrect | dsearch | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |