read the size of cell array with the same element
Show older comments
Hi I have a cell array looks like follows. How could I read the size of the cell array has the same element? In this case, I have 6 rows of 01.jpg so the first one is 6. I have 2 rows of 04.jpg so the second one is 2 and so forth. Thanks for your help!
%
01,jpg
01,jpg
01,jpg
01,jpg
01,jpg
01,jpg
04,jpg
04,jpg
05,jpg
05,jpg
...
Accepted Answer
More Answers (2)
the cyclist
on 24 May 2017
Here's one way:
C = {
'01,jpg';
'01,jpg';
'01,jpg';
'01,jpg';
'01,jpg';
'01,jpg';
'04,jpg';
'04,jpg';
'05,jpg';
'05,jpg';
}
[~,~,k] = unique(C);
C_counts = histcounts(k,[unique(k); Inf])
dpb
on 24 May 2017
[u,iu]=unique(c{:},'rows');
n=histc(iu,1:length(u));
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!