%% Wait for Button Press
% Block program execution until the user interacts with a push button.
% Create a push button with a callback that calls the uiresume function when it is clicked.

f = figure;
c = uicontrol('String','Continue','Callback','uiresume(f)');
disp('This prints immediately.');

% Wait for the user to click Continue or close the figure window. Then display a message.

uiwait(f)
disp('This prints after you click Continue or close the window.');

% Close the figure if it was not closed by the user.

try
close(f)
catch
end

% Copyright 2019 The MathWorks, Inc.