Remove a column from a matrix in GNU Octave

前端 未结 4 756
深忆病人
深忆病人 2021-02-02 05:45

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.

4条回答
  •  自闭症患者
    2021-02-02 06:11

    In case you don't know the exact number of columns or rows you can use the magic "end" index, e.g.:

    mymatrix(:,2:end)  % all but first column
    
    mymatrix(2:end,:)  % all but first row
    

    This also allows you to slice rows or columns out of a matrix without having to reassign it to a new variable.

提交回复
热议问题