1function result = waitex 2%WAITEX same as the waitexample mexFunction, just in M instead of C. 3% The only purpose of this function is to serve as a precise description of 4% what the waitexample mexFunction does. 5% 6% Example: 7% waitex % draw a waitbar, make progress, and then close the waitbar 8% h = waitex ; % same as above, except leave the waitbar on the screen 9% % and return the handle h to the waitbar. 10% 11% See also waitbar, waitexample. 12 13% Copyright 2007, T. Davis 14 15x = 0 ; 16h = waitbar (0, 'Please wait...') ; 17for i = 0:100 18 if (i == 50) 19 waitbar (i/100, h, 'over half way there') ; 20 else 21 waitbar (i/100, h) ; 22 end 23 % do some useless work 24 for j = 0:1e5 25 x = useless (x) ; 26 end 27end 28 29if (nargout > 0) 30 % h is return to the caller, leave the waitbar on the screen 31 result = h ; 32else 33 % close the waitbar, and do not return the handle h 34 close (h) ; 35end 36 37function x = useless (x) 38%USELESS do some useless work (x = useless (x) just increments x) 39x = x + 1 ; 40