How to filter the rows i donot want in a matrix
이전 댓글 표시
there is a matrix like
A=[ 0 1 0;
0 2 0;
1 0 0;
1 0 1];
compering A(1,:) and A(2,:), i choose [0 2 0];compering A(3,:) and A(4,:), i choose [1 0 1].
the final matrix i want is
A=[ 0 2 0;
1 0 1];
This is just a simple example, if the matrix is M*N, how to use matlab code to get the matrix i want.
댓글 수: 6
Chandrasekhar
2014년 4월 2일
what is the comparison criteria
valley
2014년 4월 2일
편집: Azzi Abdelmalek
2014년 4월 2일
Azzi Abdelmalek
2014년 4월 2일
What i and j represent? how are we supposed to know?
valley
2014년 4월 2일
Azzi Abdelmalek
2014년 4월 2일
Ok, have you tested my edited answer?
채택된 답변
추가 답변 (1개)
Andrei Bobrov
2014년 4월 2일
편집: Andrei Bobrov
2014년 4월 3일
blockproc(A,[2,3],@(x)max(x.data))
ADD after Valley's comment
cell2mat(accumarray...
(cumsum([true;diff(A(:,1))~=0]),(1:size(A,1))',[],@(x){max(A(x,:),[],1)}))
other variant
out = A(~any(triu(squeeze(all(bsxfun(@ge,A,reshape(A',1,size(A,2),[])),2)),1)),:)
카테고리
도움말 센터 및 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!