Accelerating the pace of engineering and science

# Documentation Center

• Trial Software
• Product Updates

## Create Numeric Arrays

This example shows how to create a numeric variable. In the MATLAB® computing environment, all variables are arrays, and by default, numeric variables are of type double (that is, double-precision values). For example, create a scalar value.

`A = 100;`

Because scalar values are single element, 1-by-1 arrays,

`whos A`

returns

```Name      Size            Bytes  Class     Attributes

A         1x1                 8  double              ```

To create a matrix (a two-dimensional, rectangular array of numbers), you can use the [] operator.

`B = [12, 62, 93, -8, 22; 16, 2, 87, 43, 91; -4, 17, -72, 95, 6]`

When using this operator, separate columns with a comma or space, and separate rows with a semicolon. All rows must have the same number of elements. In this example, B is a 3-by-5 matrix (that is, B has three rows and five columns).

```B =
12    62    93    -8    22
16     2    87    43    91
-4    17   -72    95     6
```

A matrix with only one row or column (that is, a 1-by-n or n-by-1 array) is a vector, such as

`C = [1, 2, 3]`

or

`D = [10; 20; 30]`

For more information, see:

Was this topic helpful?