How to accumulate data-sets?
-
06-11-2019 - |
Pergunta
I have vector with values between 1
and N > 1
. Some values COULD occur multiple times consecutively. Now I want to have a second row which counts the consecutively entries and remove all those consecutively occuring entries, e.g.:
A = [1 2 1 1 3 2 4 4 1 1 1 2]'
would lead to:
B = [1 1;
2 1;
1 2;
3 1;
2 1;
4 2;
1 3;
2 1]
(you see, the second column contains the number of consecutively entries!
I came across accumarray()
in MATLAB recently but I can't find any solution with it for this task since it always regards the whole vector and not only consecutively entries.
Any idea?
Nenhuma solução correta
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow