필터 지우기
필터 지우기

deleting selective multiple rows from a data matrix

조회 수: 2 (최근 30일)
Rabeya
Rabeya 2012년 4월 10일
I want to delete rows of a matrix depending on some specific values of one of its columns. Say, if A=[1,2,3,1;5,6,7,2;9,10,11,3;13,14,15,4]; B=A(:,4);
I want to delete rows of A if B<2 and B>3, that is want the second and third rows of A.
I have tried A(B,:)=[] type commands, but failed.

채택된 답변

Thomas
Thomas 2012년 4월 10일
A(~(B<2|B>3),:)

추가 답변 (1개)

Leah
Leah 2012년 4월 10일
couple of problems
B<2 & B>3
is always false you need to use a logical index to filter rows of A, B is not logical (all zeros and ones) these commands would work
A(B==2 | B==3,:)
A([2 3],:)
A(logical([0 1 1 0 ]),:)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by