How to enumerate an array?
古いコメントを表示
I want a simple enumeration of the following series a=
['465465465','465465465','465465465','31546895489','31546895489','897897979','897897979', '897897979','897897979','897897979','897897979')'
in order to get
b=(1,1,1,2,2,3,3,3,3,3,3);
I tried with
b(1:length(a))=1;
for i=2:length(a)
if isequal(a(i),a(i-1));
b(i)=b(i-1);
else
b(i)=i+1;
end
end
(but that is not the expected result)
採用された回答
その他の回答 (1 件)
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!