필터 지우기
필터 지우기

Fast sampling every other element in a matrix

조회 수: 1 (최근 30일)
Christopher
Christopher 2014년 10월 2일
댓글: Stephen23 2019년 2월 15일
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.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2014년 10월 2일
M2 = M(1:2:end,1:2:end);
  댓글 수: 3
Orongo
Orongo 2019년 2월 15일
what does the parameter 'end' mean here?
Stephen23
Stephen23 2019년 2월 15일
@Orongo: "The end function also serves as the last index in an indexing expression"

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by