17.3 Getting Pieces of Matrices
Ways to get pieces of matrices.
Matrices in Mathematica TE are represented as lists of lists. You can use all the standard Mathematica TE list-manipulation operations on matrices.
Here is a sample matrix.
In[1]:= MatrixForm[t = Array[a, {3, 3}] ]
Out[1]//MatrixForm=
This picks out the second row of the matrix.
In[2]:= t[[2]]
Out[2]=
Here is the second column of the matrix.
In[3]:= Transpose[t][[2]]
Out[3]=
This way of picking out a submatrix is convenient when you deal with bigger matrices.
In[4]:= MatrixForm[ t[[ Range[1,2], Range[2,3] ]] ]
Out[4]//MatrixForm=
This picks out the four corners of the matrix.
In[5]:= MatrixForm[ t[[ {1, 3}, {1, 3} ]] ]
Out[5]//MatrixForm=