Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help
next up previous contents
Next: Matrix operators Up: Matrix operations Previous: Creating Matrices

Picking sub-matrices

Rows, columns and submatrices can be selected from a matrix. Here are some examples. Note how parentheses (rather than square brackets) are used when manipulating matrices (the % signs introduce comments)
b = [ 1 3 5; 2 4 6]; 
c=b(2,:) % row 2
d=b(:,1) % column 1
e=b(:,2:3) % columns 2 and 3
Matrices can be composed from submatrices, so f=[d e] would produce a matrix equal to the original b.



© Cambridge University Engineering Dept
Information provided by Tim Love
2006-07-24