MATLAB Answers

Tim Mottram

Wait For Key Press?

Asked by Tim Mottram
on 11 Dec 2012

Hi Guys, I'm having a problem where I want to view consecutive 3d scatter plots. I plot the first one, then, when I'm ready I press a mouse button and it advances to the next plot using:


to advance the code . This is working fine. But in addition to this I also want to rotate the image, however using the mouse to rotate the image makes the program advance to the next plot! What I really would like is a


so I can use the mouse on the plot and when I'm done press a key to advance. So my question is:

Are there any other


which will let me use the mouse on plots freely?

Many Thanks in Advance,




No products are associated with this question.

2 Answers

Answer by Walter Roberson
on 11 Dec 2012

Use a figure WindowKeypressFcn callback.


Hi Walter, thanks for you reply. Will this method work without a GUI, as I'm not using one..

A scatter plot has to be in an axes, which has to be part of a figure. Attach the callback to that figure.

As far as MATLAB is concerned, "GUI" and "figure" are the same thing.

Answer by Muruganandham Subramanian on 12 Dec 2012
Edited by Muruganandham Subramanian on 12 Dec 2012

Otherwise, you can use keyboard, dbquit command also..


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!