Skip to Main Content Skip to Search
Product Documentation

Continue Long Statements on Multiple Lines

This example shows how to continue a statement to the next line using ellipses (...).

s = 1 - 1/2 + 1/3 - 1/4 + 1/5 ...
      - 1/6 + 1/7 - 1/8 + 1/9;

Build a long character string by concatenating shorter strings together:

mystring = ['Accelerating the pace of ' ... 
            'engineering and science'];

The start and end quotation marks for a string must appear on the same line. For example, this code returns an error, because each line contains only one quotation mark:

mystring = 'Accelerating the pace of ... 
            engineering and science'

An ellipses outside a quoted string is equivalent to a space. For example,

x = [1.23...
4.56];

is the same as

x = [1.23 4.56];
  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS