Main Content

square brackets, [ ]

Array creation and concatenation, element deletion, argument assignment

Syntax

Description

Square brackets [] create and concatenate arrays, create empty matrices, delete array elements, and enclose function output arguments. For instance, [10 12 -3] creates a vector with three elements.

example

Examples

expand all

Create a vector, concatenate a new row, and delete a column.

X = [10 12 -3]
X = 1×3

    10    12    -3

X = [X; 3 6 9]
X = 2×3

    10    12    -3
     3     6     9

X(:,1) = []
X = 2×2

    12    -3
     6     9

Call a function with three output arguments.

A = [5 7 1]; 
B = [3 1 1];
[C,iA,iB] = union(A,B)
C = 1×4

     1     3     5     7

iA = 3×1

     3
     1
     2

iB = 
1

Version History

Introduced before R2006a