フィルターのクリア

How to find consecutive number of strings along with their starting position?

1 回表示 (過去 30 日間)
Md.Mobasshir Arshed
Md.Mobasshir Arshed 2016 年 4 月 10 日
回答済み: Azzi Abdelmalek 2016 年 4 月 10 日
Assume i have cells containing values as
a,a,a,b,b,a,a,c,c,d,d
now how can i find number of a s along with the staring position. the answer would be like 3 starting at 0, and 2 starting at 5.
anyone please help...

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 10 日
v={'a','a','a','b','b','a','a','c','c','d','d'}
idx=ismember(v,'a')
ii=strfind([ 0 idx],[0 1]);
jj=strfind([idx,0],[1 0]);
out=[ii'-1 (jj-ii)'+1]

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by