How to pause execution of program until a keypress
553 次查看（过去 30 天）
Hi, I have two parts in my Matlab program and I want to pause first part until keypress event by user. I searched to pause function and found waitforbuttonpress. However I do not know how to use it. Can anyone suggest a good method to pause until a keypress or a specific keypress (y or Y) etc.? Thanks.
Sagar Damle 2014-3-12
Use function 'pause'. e.g.
a = 20;
b = 40;
disp('Press a key !') % Press a key here.You can see the message 'Paused: Press any key' in % the lower left corner of MATLAB window.
Just for information : If you want to terminate your MATLAB program abruptly,you can use 'Ctrl+C'
key combination.The same method is used to terminate a command in 'Command Prompt'.
Similar commands in Command Prompt and MATLAB-