[ ]
Name: Square brackets
Uses:
• Array construction
• Array concatenation
• Empty matrix and array element deletion
• Multiple output argument assignment
Description: Square brackets enable array construction and concatenation, creation of
empty matrices, deletion of array elements, and capturing values returned by a function.
Examples
Construct a three-element vector:
X = [10 12 -3]
Add a new bottom row to a matrix:
A = rand(3);
A = [A; 10 20 30]
Create an empty matrix:
A = []
Delete a matrix column:
A(:,1) = []
Capture three output arguments from a function:
[C,iA,iB] = union(A,B)
More Information
• “Creating, Concatenating, and Expanding Matrices”
• horzcat
• vertcat
2 Program Components
2-10
Name: Square brackets
Uses:
• Array construction
• Array concatenation
• Empty matrix and array element deletion
• Multiple output argument assignment
Description: Square brackets enable array construction and concatenation, creation of
empty matrices, deletion of array elements, and capturing values returned by a function.
Examples
Construct a three-element vector:
X = [10 12 -3]
Add a new bottom row to a matrix:
A = rand(3);
A = [A; 10 20 30]
Create an empty matrix:
A = []
Delete a matrix column:
A(:,1) = []
Capture three output arguments from a function:
[C,iA,iB] = union(A,B)
More Information
• “Creating, Concatenating, and Expanding Matrices”
• horzcat
• vertcat
2 Program Components
2-10
