Main Content

ellipsis, ...

R2026b

Line continuation

Syntax

Description

The ellipsis symbol (...) continues the current command on the next line. If three or more periods occur before the end of a line, then MATLAB® ignores the rest of the line and continues to the next line. This behavior effectively makes a comment out of anything on the current line that follows the three periods.

MATLAB interprets the ellipsis as a space character. Therefore, multi-line commands must be valid as a single line with the ellipsis replaced by a space character.

example

Examples

expand all

Continue a function call on the next line.

vname = "Var1";
value = 10;
sprintf(["The current value " + ...
    "of %s is %d"],vname,value)
ans = 
"The current value of Var1 is 10"

Break a character vector over multiple lines and concatenate the lines together.

S = ['If three or more periods occur before the ' ...
    'end of a line, then the rest of that line is ' ...
    'ignored and MATLAB continues to the next line'];

To comment out one line in a multi-line command, use ... at the beginning of the line to ensure that the command remains complete. If you use % to comment out a line, the command produces an error.

y = 1 + ...
    2 + ...
  % 3 + ...
    4

However, this code runs properly because the third line does not produce a gap in the command.

y = 1 + ...
    2 + ...
... 3 +
    4
y = 
7

Version History

Introduced before R2006a