Accumulating Unique Set Values
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    
I have 10 sets (each set includes 1s and 0s: 1 means element selected) and trying to find the unique sets and store its element indices. But when there is only one unique set following code gives error. How can I fix it? Thanks for the help.
[Rw,Cl] = find(unique(FSet,'rows','stable'));
UnqFS = accumarray(Rw,Cl,[], @(f) {sort(f).'});
celldisp(UnqFS)
댓글 수: 2
  Jos (10584)
      
      
 2019년 2월 20일
				What is Fset? A 10-by-N array? 
Perhaps you can give a (small) example of the input and expected output?
채택된 답변
  Jos (10584)
      
      
 2019년 2월 20일
        My suggestion: first find the unique rows of Fset, and then get the column indices for each row
FSet = randi(2,10,3) -1 % example
UFS = unique(FSet,'rows','stable')
UnqFS = arrayfun(@(r) find(UFS(r,:)), 1:size(UFS,1), 'un',0)
celldisp(UnqFS)
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!