Desktop Tools and Development Environment Previous page   Next Page

Enter Multiple Lines Without Running Them

To enter multiple lines before running any of them, use Shift+Enter or Shift+Return after typing a line. This is useful, for example, when entering a set of statements containing keywords, such as if ... end. The cursor moves down to the next line, which does not show a prompt, where you can type the next line. Continue for more lines. Then press Enter or Return to run all of the lines.

This allows you to edit any of the lines you entered before you pressing Enter or Return.

Entering Multiple Functions in a Line

To enter multiple functions on a single line, separate the functions with a comma ( , ) or semicolon ( ; ). Using the semicolon instead of the comma will suppress the output for the command preceding it. For example, put three functions on one line to build a table of logarithms by typing

format short; x = (1:10)'; logs = [x log10(x)]

and then press Enter or Return. The functions run in left-to-right order.

Entering Long Statements

If a statement does not fit on one line, enter three periods (...) , also called dots, stops, or an ellipsis, at the end of the line to indicate it continues on the next line. Then press Enter or Return. Continue typing the statement on the next line. You can repeat the ellipsis to add a line break after each line until you complete the statement. When you finish the statement, press Enter or Return.

For items in single quotation marks, such as strings, you must complete the string in the line on which it was started. For example, completing a string as shown here

headers = ['Author Last Name, Author First Name, ' ...
'Author Middle Initial']

results in

headers =
Author Last Name, Author First Name, Author Middle Initial

MATLAB produces an error when you do not complete the string, as shown here:

headers = ['Author Last Name, Author First Name, ...
Author Middle Initial']

??? headers = ['Author Last Name, Author First Name, ...
Error: Missing variable or function.

Note that MATLAB ignores anything appearing after the ... on a line, and continues processing on the next line. This effectively creates a comment out of the text following the ... on a line. For more information, see Commenting Out Part of a Statement.


Previous page  Cut, Copy, Paste, and Undo Features Recalling Previous Lines Next page

© 1994-2005 The MathWorks, Inc.