Chapter Contents Previous Next
 Understanding the Language

## Matrix Literals

A matrix literal is a matrix represented by its values. When you represent a matrix by a literal, you are simply specifying the values of each element of the matrix. A matrix literal can have a single element (a scalar) or have many elements arranged in a rectangular form (rows × columns). The matrix can be numeric (all elements are numeric) or character (all elements are character). The dimension of the matrix is automatically determined by the way you punctuate the values.

If there are multiple elements, use braces ({ }) to enclose the values and commas to separate the rows. Within the braces, values must be either all numeric or all character. If you use commas to create multiple rows, all rows must have the same number of elements (columns).

The values you input can be any of the following:

• a number, with or without decimal points, possibly in scientific notation (such as 1E-5)
• a character string. Character strings can be enclosed in either single quotes (') or double quotes ("), but they do not necessarily need quotes. Quotes are required when there are no enclosing braces or when you want to preserve case, special characters, or blanks in the string. If the string has embedded quotes, you must double them (for example, WORD='Can''t'). Special characters can be any of the following: ?   =   *   :   (   ).
• a period (.), representing a missing numeric value
• numbers in brackets ([ ]), representing repetition factors

 Chapter Contents Previous Next Top