waitbar - Open waitbar

Syntax

h = waitbar(x,'message')
waitbar(x,'message','CreateCancelBtn','button_callback')
waitbar(...,property_name,property_value,...)
waitbar(x)
waitbar(x,h)
waitbar(x,h,'updated message')

Description

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

h = waitbar(x,'message') displays a waitbar of fractional length x. The waitbar figure is modal. Its handle is returned in h. The argumentx must be between 0 and 1.

waitbar(x,'message','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 figure properties for the waitbar.

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(x,h,'updated message') updates the message text in the waitbar figure, in addition to setting the fractional length to x.

Example

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

h = waitbar(0,'Please wait...');
for i=1:100, % computation here %
waitbar(i/100)
end
close(h) 

See Also

Predefined Dialog Boxes for related functions

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS