unique set from file

2 ビュー (過去 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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by