finding unique phrases and their frequency in a cell array
古いコメントを表示
Hi,
I usually deal with numbers but never with text. I have a cell array of phrases(attached the mat file) . I want to know what are these uniques phrases and the frequency of each phrase (how many time it appears). Any help would be greatly appreciated.
採用された回答
その他の回答 (1 件)
Danielle Leblance
2020 年 4 月 14 日
編集済み: Danielle Leblance
2020 年 4 月 14 日
0 投票
1 件のコメント
Star Strider
2020 年 4 月 14 日
Your file did not have blank cells.
Experiment with this:
D = load('matlab.mat');
nbEmployees = D.nbEmployees;
nbEmployees = nbEmployees(cellfun(@(x)~isempty(x), nbEmployees),:);
[uE,~,ix] = unique(nbEmployees);
tally = accumarray(ix, 1);
Out = table(uE, tally, 'VariableNames',{'Phrase','Frequency'})
That runs without error, and assumes that ‘blank’ elements are ‘empty’ elements.
.
カテゴリ
ヘルプ センター および File Exchange で Operators and Elementary Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
