필터 지우기
필터 지우기

Maintain shape of logical index mask

조회 수: 4 (최근 30일)
Garima Sharma
Garima Sharma 2017년 6월 12일
댓글: Garima Sharma 2017년 6월 13일
I have a matrix A=[1,2,3;4,5,6]. From this, I want to remove (by row), z=[1,5], to return the matrix B=[2,3;4,6]. I'm trying to use logical indexing to do this, but that returns a vector instead of the matrix B.
if true
B=A(A~=z(:,1))
end

채택된 답변

Andrei Bobrov
Andrei Bobrov 2017년 6월 12일
편집: Andrei Bobrov 2017년 6월 12일
Aout = A';
Aout = reshape(Aout(Aout ~= z(:)'),[],2)';
or
Aout = A';
Aout = reshape(Aout(~ismember(Aout,z)),[],2)';

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by