3.5. Matrix Subscripts/Indices

The elements of a matrix can be specified/accessed by specifying their respective row and column numbers. The first index refers to the row number and second index refers to column number. The element in ith row and the jth column of a matrix A is denoted by A(i, j). For example, A (2, 3) refers to the element in the second row and the third column of the matrix A.

3.5.1. Sub-matrices/Sub-arrays

Subsets of arrays can be selected as if they are separate arrays. MATLAB allows portions of a matrix to be specified using colon operator. For example, statement B(1:4, 2:8) specifies rows 1 to 4 and columns 2 to 8 of the matrix B.

For matrix A defined below:

A= [1    3    9
    5   10   15
    0    0   -5];

The command:

A(1:2, 2:3)

when executed ...

Get MATLAB® and Its Applications in Engineering: [Based on MATLAB 7.5 (R2007b)] now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.