Why does MATLAB produce an error when I execute WAITFORBUTTONPRESS and close the figure window without clicking on the figure?
7 views (last 30 days)
Show older comments
I am using the WAITFORBUTTONPRESS function to block caller input until a mouse click is detected or a key is pressed.
While MATLAB is waiting for a button press, if I close the figure window by clicking on the close icon at the top-right corner of the window, MATLAB throws the following error:
??? Error using ==> waitforbuttonpress
waitforbuttonpress exit because all figures have been deleted
This is not documented in the help page for WAITFORBUTTONPRESS.
Accepted Answer
MathWorks Support Team
on 7 Jan 2010
This change has been incorporated into the documentation in Release 2009b (R2009b). For previous releases, read below for any additional information:
This is an error in the documentation for MATLAB 7.7 (R2008b) within the WAITFORBUTTONPRESS section. The documentation should read as follows:
You can interrupt WAITFORBUTTONPRESS by typing Ctrl+C, but an error
results unless the function is called from within a try-catch block.
WAITFORBUTTONPRESS also returns an error if you close the
figure by clicking the X(close) button unless you call WAITFORBUTTONPRESS within a try-catch block.
0 Comments
More Answers (0)
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!