If same value apperas in array count +1
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
First Last
el 14 de Sept. de 2021
Comentada: First Last
el 14 de Sept. de 2021
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
0 comentarios
Respuesta aceptada
Walter Roberson
el 14 de Sept. de 2021
input = [ 1 2 3 4 1 2 3 4 1 2 3 4 ];
output = sum(triu(input' == input))
Más respuestas (1)
KSSV
el 14 de Sept. de 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
Ver también
Categorías
Más información sobre Calendar en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!