I have a vector of information, say:
Info = [10, 20, 10, 30, 500, 400, 67, 350, 20, 105, 15];
and another a vector of IDs, say:
Info_IDs = [1, 2, 1, 4, 2, 3, 4, 1, 3, 1, 2];
I would like to obtain a matrix that is defined as follows:
Result =
10 10 350 105
20 500 15 0
400 20 0 0
30 67 0 0
Where every row shows the values of Info
corresponding to a different ID. As seen in this short example, the number of values per ID
differs in each row.
I'm working with large amounts of data (Info
is 1x1000000 and Info_IDs
is 1x25000), so
I would like to achieve this Result
matrix preferably without loops. One way I was thinking about is to compute the histogram per ID and store this info (therefore Result
would not contain the original info, but the binned info).
Thank you all in advance for your input.