This question is the result of MatLab (or any other language) to convert a matrix or csv to put the values ββof the second column in one row, if the value of the 1st column is the same? and Group values ββin different rows at the index of the first column
If
A = [2 3 234 ; 2 44 99999; 2 99999 99999; 3 123 99; 3 1232 45; 5 99999 57] 1st column | 2nd column | 3rd column -------------------------------------- 2 3 234 2 44 99999 2 99999 99999 3 123 99 3 1232 45 5 99999 57
I want to make
1st col | 2nd col | 3rd col | 4th col | 5th col | 6th col| 7th col -------------------------------------------------------------------- 2 3 234 44 3 123 99 1232 45 5 57
That is, for each number in the 1st column of A, I want to put the EXCEPT numbers "99999"
If we ignore the part βexcept 99999β, we can write the group values ββin different rows at the index of the first column
[U, ix, iu] = unique(A(:,1)); vals = reshape(A(:, 2:end).', [], 1); %'// Columnize values subs = reshape(iu(:, ones(size(A, 2) - 1, 1)).', [], 1); %'// Replicate indices r = accumarray(subs, vals, [], @(x){x'});
But obviously this code will not ignore 99999.
I assume there are two ways:
1. first make r, and then remove 99999 2. remove 99999 first, and then make r
Anyway, I just want faster.
Thank you in advance!