… tells MATLAB to ignore the rest of the line, and continue the execution of the current statement to the next line. This operator is often referred as “the ellipsis”, and MATLAB interprets it as a space character.
Use the ellipsis to create multiline statements, and to comment out parts of multiline statements.
% Sum numbers in multiple lines y = 1 + ... 2 + ... 3;
y = 6
% Create a matrix using one line per row matrix = [... 1, 2, 3; ... 4, 5, 6; ... 7, 8, 9 ... ];
matrix = 1 2 3 4 5 6 7 8 9
% Build a long string str = ['Visit the ImageProcessingLog.Com website and find calls for papers', ... ', news, jobs, tutorials, opinion articles, and exams about', ... ' digital image processing and related fields.'];
str = Visit the ImageProcessingLog.Com website and find calls for papers, news, jobs, tutorials, opinion articles, and exams about digital image processing and related fields.
% Comment out parts of a multiline statement newMatrix = [... 1, 2, 3; ... ... 4, 5, 6; ... 7, 8, 9 ... ];
newMatrix = 1 2 3 7 8 9
I recommend the following book to learn more on how the line continuation operator works in MATLAB:
This book was the winner of a Textbook Excellence Award. The first chapter explains the line continuation operator, among other introductory topics like random numbers generation, trigonometry, and how to get help in MATLAB.
I also recommend the other tutorials in this series.
- Getting Help in MATLAB
- Valid Identifiers in MATLAB
- Reserved Words in MATLAB
- Comments in MATLAB
- Multiline Statements in MATLAB
- How to Execute a Command Automatically When MATLAB Starts
- How to Execute a Command Automatically When MATLAB Quits
- How to Save the Workspace Variables to a .MAT File in MATLAB
- How to Load the Variables in a .MAT File into the Workspace in MATLAB
- How to Delete a Variable in MATLAB
I hope you have learned how to use the line continuation operator in MATLAB. The source code developed in this tutorial is available at this page.