In GNU Octave, I want to be able to remove specific columns from a matrix. In the interest of generality. I also want to be able to remove specific rows from a matrix.
How to remove columns 2 and 4:
columns_to_remove = [2 4];
matrix(:,columns_to_remove)=[]
Illustrated:
mymatrix = eye(5)
mymatrix =
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
columns_to_remove = [2 4];
mymatrix(:,columns_to_remove)=[]
mymatrix =
1 0 0
0 0 0
0 1 0
0 0 0
0 0 1