Fast sampling every other element in a matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a matrix M. I want to delete every other column and every other row. However, I already know how to do this as:
M = rand(100,11);
M2=M;
M2(:,2:2:end)=[];
M2(2:2:end,:)=[];
I will have to do this operation on large matrices many times in a loop, thus I am wondering if matlab has a built-in function to do this faster. Thanks.
댓글 수: 0
채택된 답변
Andrei Bobrov
2014년 10월 2일
M2 = M(1:2:end,1:2:end);
댓글 수: 3
Stephen23
2019년 2월 15일
@Orongo: "The end function also serves as the last index in an indexing expression"
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!