How to eliminate certain columns from a matrix
조회 수: 175 (최근 30일)
이전 댓글 표시
If I need to remove any column how do I do it?
For example:
s is a mxn matrix.I need to remove the odd columns i,e, the 1st,3rd.. columns.
댓글 수: 0
채택된 답변
추가 답변 (1개)
Manvi Goel
2019년 6월 13일
Let the matrix be a.
You can remove the odd columns of a matrix by :
a(:,1:2:end) = []
% 1:2:end runs a loop from 1 till the numbe rof columns, increments the index by 2 every time and
% empties the column with that index.
Or use the following command to remove and column with index 'i'
a(:, i) = []
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!