Page 66 - A Guide to MATLAB for Beginners and Experienced Users
P. 66
Fine-Tuning Your M-Files 47
The command keyboard is an interactive version of pause. If you have
the line keyboard in your M-file, then when MATLAB reaches it,
execution of your program is interrupted, and a new prompt appears
withthe letter K before it. At this point you can type any normal MATLAB
command. This is useful if you want to examine or reset some variables
in the middle of a script run. To resume the execution of your script, type
return; i.e., type the six letters r-e-t-u-r-n and press the ENTER key.
In some cases, you might prefer input. For example, if you include the
line var = input(’Input var here: ’) in your script, when MAT-
LAB gets to that point it will print “Input var here:” and pause while
you type the value to be assigned to var.
Finally, remember that you can stop a running M-file by typing CTRL+C.
This is useful if, at a pause or input statement, you realize that you
want to stop execution completely.