MATLAB Function Reference    

Display waitbar



A waitbar shows what percentage of a calculation is complete, as the calculation proceeds.

h = waitbar(x,'title') displays a waitbar of fractional length x. The handle to the waitbar figure is returned in h. x must be between 0 and 1.

waitbar(x,'title','CreateCancelBtn','button_callback') specifying CreateCancelBtn adds a cancel button to the figure that executes the MATLAB commands specified in button_callback when the user clicks the cancel button or the close figure button. waitbar sets both the cancel button callback and the figure CloseRequestFcn to the string specified in button_callback.

waitbar(...,property_name,property_value,...) optional arguments property_name and property_value enable you to set corresponding waitbar figure properties.

waitbar(x) subsequent calls to waitbar(x) extend the length of the bar to the new position x.

waitbar(x,h) extends the length of the bar in the waitbar h to the new position x.


waitbar is typically used inside a for loop that performs a lengthy computation. For example,

See Also

Predefined Dialog Boxes for related functions

  wait waitfor