Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

keyboard

Input from keyboard

Syntax

Description

example

keyboard pauses execution of a running program and gives control to the keyboard. Place the keyboard function in a program at the location where you want MATLAB® to pause. When the program pauses, the prompt in the Command Window changes to K>>, indicating that MATLAB is in debug mode. You then can view or change the values of variables to see if the new values produce expected results.

The keyboard function is useful for debugging your functions.

Examples

collapse all

Use the keyboard command to pause execution of a program and modify a variable before continuing.

Create a file, buggy.m, containing these statements.

function z = buggy(x)
n = length(x);
keyboard
z = (1:n)./x;

Run buggy.m. MATLAB pauses at line 3, where the keyboard command is located.

buggy(5)

Multiply the variable x by 2 and continue running the program. MATLAB executes the rest of the program using the new value of x.

x = x * 2
dbcont

More About

collapse all

Tips

  • To terminate debug mode and continue execution, use the dbcont command.

  • To terminate debug mode and exit the file without completing execution, use the dbquit command.

See Also

| | |

Introduced before R2006a


Was this topic helpful?