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
...

 採用された回答

Guillaume
Guillaume 2017 年 5 月 24 日

0 投票

Please use valid matlab syntax in your question, so it's not ambiguous. Assuming that your cell array is of the form:
c = {'01,jpg'
'01,jpg'
'01,jpg'
'01,jpg'
'01,jpg'
'01,jpg'
'04,jpg'
'04,jpg'
'05,jpg'
'05,jpg'}
This would work:
[~, ~, id] = unique(c, 'stable');
sequencelengths = diff(find(diff([-Inf; id; Inf])))

その他の回答 (2 件)

the cyclist
the cyclist 2017 年 5 月 24 日

1 投票

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
dpb 2017 年 5 月 24 日

0 投票

[u,iu]=unique(c{:},'rows');
n=histc(iu,1:length(u));

カテゴリ

ヘルプ センター および File Exchange で Convert Image Type についてさらに検索

タグ

質問済み:

2017 年 5 月 24 日

回答済み:

dpb
2017 年 5 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by