MATLAB Answers

Pan

what is the uiwait?

Asked by Pan
on 18 Aug 2012

what is the uiwait?

then, how to use it?

If you know, please tell me ,thank you!!

  1 Comment

Jan Simon
on 18 Aug 2012

Did you read "help uiwait" and "doc uiwait" already?

Tags

Products

No products are associated with this question.

3 Answers

Answer by Matt Fig
on 18 Aug 2012
Edited by Matt Fig
on 18 Aug 2012
 Accepted answer

uiwait(FIG_handle) blocks execution until either UIRESUME is called or the figure FIG is destroyed (closed). uiwait with no input arguments is the same as uiwait(gcf). In this example, a figure is created along with a pushbutton. After the figure is created, uiwait is called until you push the button. When you push the button, the callback calls uiresume.

f = figure('pos',[30 800 250 150]);
h = uicontrol('Position', [20 20 200 40], 'String', 'Continue', ...
              'Callback', 'uiresume(gcbf);close(gcbf)');
disp('This will print immediately');
uiwait(gcf);
disp('This will print after you click Continue'); 

  2 Comments

Pan
on 18 Aug 2012

Hi,could I ask other question.

The uiwait could use in the button?

Jan Simon
on 22 Nov 2012

Accpted.


Answer by Azzi Abdelmalek
on 18 Aug 2012
Edited by Azzi Abdelmalek
on 18 Aug 2012

%uiwait blocks the execution of the program until a current figure is closed

%example

 t=0:0.1:2*pi;y=sin(t);
plot(t,y)
uiwait(gcf)% 
%at this point the program will wait you close the curent figure and the continue
y=cos(t);
plot(t,y)

% for more details look at matlab help http://www.mathworks.com/help/techdoc/ref/uiwait.html

  2 Comments

Pan
on 18 Aug 2012

Hi,could I ask other question.

The uiwait could use in the button?

Azzi Abdelmalek
on 18 Aug 2012

look at the example given by Matt Fig


Answer by Image Analyst
on 18 Aug 2012

uiwait() will pause execution of your program until you do something, such as close or interact with some dialog box. For example if you do

msgbox('This will not stop. It will keep running code.');

Then it will pop up a message box and continue on with the subsequent code. It won't wait for the user to click the OK button. But if you wrap it in a uiwait(), it will wait for the user to click OK:

uiwait(warndlg('You have an anomalous situation here.  Click OK to continue'));
uiwait(msgbox('I will wait for you to click OK.'));

  0 Comments


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today