How to find unique elements from every row within matrix??
조회 수: 3 (최근 30일)
이전 댓글 표시
y = [ 90 90 -45 0 0 45 45 0 -45 15 30 -30 75 -45 75 -75
90 90 -45 0 0 -45 -45 0 -45 15 30 -30 75 -45 75 -45
90 90 -45 0 0 45 45 0 -45 15 30 -30 75 -45 75 -30
90 90 -45 0 0 45 45 0 -45 15 30 -30 75 -45 75 0
90 90 -45 0 0 45 45 0 -45 15 30 -30 75 -45 75 15
90 90 -45 0 0 45 45 0 -45 15 30 -30 75 -45 75 30
90 90 45 0 0 45 45 0 45 15 30 -30 75 45 75 45
90 90 -45 0 0 45 45 0 -45 15 30 -30 75 -45 75 75
90 90 -45 0 0 45 45 0 -45 15 30 -30 75 -45 75 90];
unique(y) =9;
Please tell me to count unique value in every row, and if unique elements in row less than 9, that row should be deleted.
댓글 수: 0
채택된 답변
Andrei Bobrov
2016년 2월 29일
y0 = sort(y,2);
out = y(sum([ones(size(y,1),1),diff(y0,[],2)~=0],2) >= 9,:);
댓글 수: 1
Andrei Bobrov
2016년 2월 29일
use
out = y(sum([ones(size(y,1),1),diff(y0,[],2)~=0],2) >= ...
numel(unique(y)),:);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!