How to 'unfold' or 'reverse groupcounts?
Show older comments
Hey - is there a way to reverse a groupcount procedure?
I have a two column matrix describing the group number and group occurrence. I would like to convert this cummulative vector to a vector with a row for each occurrence:
[1 2;
2 1;
3 3;
4 1]
I would like to get
[1 1 2 3 3 3 4];
It is essentially reversing groupcounts.
Thanks - Adam
Answers (1)
Bruno Luong
on 20 Jul 2020
Edited: Bruno Luong
on 20 Jul 2020
c = [1 2;
2 1;
3 3;
4 1]
repelem(c(:,1).',c(:,2).')
Categories
Find more on Tables 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!