Deleting a row y from a matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
If I have a matrix A and I want to delete all the rows, y, in A such that y=[1 2 3];
Ex:
A=[ 1 2 3; 4 5 6; 7 8 9; 1 2 3]; y=[1 2 3];
I want to remove all the y vectors from A so that I have:
A=[4 5 6; 7 8 9];
댓글 수: 0
답변 (1개)
JESUS DAVID ARIZA ROYETH
2020년 2월 17일
편집: JESUS DAVID ARIZA ROYETH
2020년 2월 17일
A(all(A==y,2),:)=[]
edit previous versions:
A(all(A==repmat(y,size(A,1),1),2),:)=[]
댓글 수: 6
JESUS DAVID ARIZA ROYETH
2020년 2월 17일
try now:
A=[ 1 2 3; 4 5 6; 7 8 9; 1 2 3]; y=[1 2 3];
A(all(A==repmat(y,size(A,1),1),2),:)=[]
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!