Programming Previous page   Next Page

Space Character

The space character serves a purpose similar to the comma in that it can be used to separate row elements in an array constructor, or the values returned by a function.

Row Element Separator

You have the option of using either commas or spaces to delimit the row elements of an array when constructing the array. To create a 1-by-3 array, use

When indexing into an array, you must always use commas to reference each dimension of the array.

Function Output Separator

Spaces are allowed when specifying a list of values to be returned by a function. You can use spaces to separate return values in both function declarations and function calls:

Slash and Backslash -- / \

The slash (/) and backslash (\) characters separate the elements of a path or directory string. On Windows-based systems, both slash and backslash have the same effect. On UNIX-based systems, you must use slash only.

On a Windows system, you can use either backslash or slash:

On a UNIX system, use only the forward slash:

Square Brackets -- [ ]

Square brackets are used in array construction and concatenation, and also in declaring and capturing values returned by a function.

Array Constructor

To construct a matrix or array, enclose all elements of the array in square brackets:

Concatenation

To combine two or more arrays into a new array through concatenation, enclose all array elements in square brackets:

Function Declarations and Calls

When declaring or calling a function that returns more than one output, enclose each return value that you need in square brackets:


Previous page  Percent -- % MATLAB Functions Next page

© 1994-2005 The MathWorks, Inc.