what does these three dots mean in this equation...

60 views (last 30 days)
diff_im = diff_im + ...
delta_t*(...
(1/(dy^2))*cN.*nablaN + (1/(dy^2))*cS.*nablaS + ...
(1/(dx^2))*cW.*nablaW + (1/(dx^2))*cE.*nablaE + ...
(1/(dd^2))*cNE.*nablaNE + (1/(dd^2))*cSE.*nablaSE + ...
(1/(dd^2))*cSW.*nablaSW + (1/(dd^2))*cNW.*nablaNW );

Accepted Answer

Walter Roberson
Walter Roberson on 8 Jan 2012
The three dots mean line continuation. MATLAB expressions normally end at the end of the line unless they are specifically continued (exception: within the [] list building operator.)
  8 Comments
Jan
Jan on 1 Feb 2017
Edited: Jan on 1 Feb 2017
@Adam:
using the line break operator as a comment tool is horrible!
Do you mean the "line continuation operator" or that the linebreak in the text is interpreted as row break in the matrix? I agree with both.
Adam
Adam on 1 Feb 2017
Well, I was meaning the line continuation operator. I have been known to have functions in C++ where I comment out one argument temporarily from the middle of the list (either formatted with the full function signature on one line or, as I often do in Matlab, with one argument per line), but at least there it has more of a look of being commented out, being surrounded by operators that would not otherwise be anywhere near.
The idea of having 1 ... on one line and ... 2 on the next line meaning that only the 1 is actually part of the code is not programmer-friendly. Having just tried it for the first time though I notice the '2' does at least turn green to show it is commented out.

Sign in to comment.

More Answers (1)

Jan
Jan on 1 Feb 2017
Edited: Jan on 1 Feb 2017
I summarize the important comments of Stephen Cobeldick and Steven Lord above to make this more prominent:
Beside the line continuation, the ellipsis '...' starts a comment also:
To comment out part of a statement that spans multiple lines, use an ellipsis (...)
instead of a percent sign.
Using a % is interpreted as line break and therefore as an implicit row break of the data:
header = [1 ...
... 2 % line break commented away
3]
>> [1, 3]
header = [1 ...
% 2 % line break interpreted as row break
3]
>> [1; 3]
header = [1, ...
% 2
3]
>> [1; 3] % ???
header = [1; ...
... 2
3]
>> [1; 3] % As intented obviously
Only the last version looks intuitive for me. I'm still convinced that it was a bad design idea to allow spaces as column-separators and linebreaks as row-separators because this leads to ambiguities.

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!