unique set from file

조회 수: 1 (최근 30일)
Sanjana Sankar
Sanjana Sankar 2019년 7월 29일
댓글: Sanjana Sankar 2019년 7월 29일
I have a .mat file with 14994x31 cells with random alphabets in the cells. I need to find the unique set. I know it is going to be the set of all alphabets only. But I want to find exactly which alphabets are present (if not all). Is the anyway to find out the unique set for the entire file and not just row by row?
  댓글 수: 2
Adam Danz
Adam Danz 2019년 7월 29일
Could you give us an example of the cell array?
Sanjana Sankar
Sanjana Sankar 2019년 7월 29일
'!' 'a:' 'l' 't' '@' [] []
'?' 'a:' 'l' 't' '@' 's' 't'
'/' 'a' 'b' 'a' 'n' 'd' 'A~'
3 different rows

댓글을 달려면 로그인하십시오.

채택된 답변

Adam Danz
Adam Danz 2019년 7월 29일
편집: Adam Danz 2019년 7월 29일
c = {'!' 'a:' 'l' 't' '@' [] []
'?' 'a:' 'l' 't' '@' 's' 't'
'/' 'a' 'b' 'a' 'n' 'd' 'A~'};
cUnq = unique(c(cellfun(@ischar,c)));
Result
cUnq =
13×1 cell array
{'!' }
{'/' }
{'?' }
{'@' }
{'A~'}
{'a' }
{'a:'}
{'b' }
{'d' }
{'l' }
{'n' }
{'s' }
{'t' }
If you want to keep the unique elements in their original order,
cUnq = unique(c(cellfun(@ischar,c)),'stable');

추가 답변 (1개)

Joel Handy
Joel Handy 2019년 7월 29일
편집: Joel Handy 2019년 7월 29일
c = {'!' 'a:' 'l' 't' '@' [] []
'?' 'a:' 'l' 't' '@' 's' 't'
'/' 'a' 'b' 'a' 'n' 'd' 'A~'};
for rowIdx = 1:size(c,1)
cString(rowIdx) = string([c{rowIdx,:}])
end
uniqueSets = unique(cString)
  댓글 수: 1
Sanjana Sankar
Sanjana Sankar 2019년 7월 29일
Thank you. This also works!!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by