finding unique phrases and their frequency in a cell array
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (1)
Danielle Leblance
el 14 de Abr. de 2020
Editada: Danielle Leblance
el 14 de Abr. de 2020
0 votos
1 comentario
Star Strider
el 14 de Abr. de 2020
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.
.
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
