Summary: This module provides a link to the Mathworks tutorial on MATLAB vectors and arrays, and adds a useful piece of information not covered in the tutorial.
Note: You are viewing an old version of this document. The latest version is available here.
An excellent tutorial on how to use MATLAB's vector and array capabilities is at the Mathworks MATLAB tutorial page.
One useful method of accessing entire rows or entire columns of the matrix is not mentioned in the tutorial. Suppose that the matrix A is defined as
>> A = [1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20]
A =
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
An entire row of A can be obtained by specifying a single ":" as the column index:
>> A(2,:)
ans =
6 7 8 9 10
Similarly, an entire column of A can be obtained by specifying a single ":" as the row index:
>> A(:,3)
ans =
3
8
13
18