2.50 delete one column from a matrix
Example, Given the folowing 2D matrix \(A\) delete say the second column
\(\begin {pmatrix} 1 & 2 & 3\\ 4 & 5 & 6\\ 7 & 8 & 9 \end {pmatrix}\)
2.50.1 Mathematica
mat={{1,2,3},
{4,5,6},
{7,8,9}};
mat[[All,2]]=Sequence[];
mat
|
Out[93]= {{1,3},
{4,6},
{7,9}}
|
| or a little longer solution using Pick
{nRow,nCol}=Dimensions[mat];
mask=Table[True,{nRow},{nCol}];
mask[[All,2]]=False;
mat=Pick[mat,mask];
mat
|
Out[98]= {{1,3},
{4,6},
{7,9}}
|
2.50.2 Matlab
A=[1 2 3;4 5 6;7 8 9];
A(:,2)=[]
|
A =
1 3
4 6
7 9
|
2.50.3 Maple
A:=Matrix([[1,2,3],[4,5,6],[7,8,9]]);
A:=LinearAlgebra:-DeleteColumn(A,2);
|
\[ \left [ \begin {array}{cc} 1&3\\ \noalign {\medskip }4&6 \\ \noalign {\medskip }7&9\end {array} \right ] \] |