If same value apperas in array count +1
Show older comments
Hello Guys,
I have an array with nx1, now i need a code to count + 1 if the same value apperas later in the array, for example:
input = [ 1 2 3 4 1 2 3 4 1 2 3 4 ];
output = [ 1 1 1 1 2 2 2 2 3 3 3 3];
Thank you
Accepted Answer
More Answers (1)
KSSV
on 14 Sep 2021
input = [ 1 2 3 4 1 2 3 4 1 2 3 4 ];
a = reshape(input,[],3)' ;
[c,ia,ib] = unique(a,'rows') ;
ib
1 Comment
First Last
on 14 Sep 2021
Categories
Find more on Calendar 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!