From: Emily Bauner on 23 May 2010 18:15 Hi all, I'm looking for a fast way to distribute vector elements in a given matrix such that identical elements are listed in the same matrix row; the tricky part is that the vector has fewer elements than the matrix. For instance, assume that I have vector A: A = [1 2 2 3 3 3 4 4 4 4 5 5 5 5 6 6 6 7 7 8] I need some command that gives me matrix B, where B is B = 1 0 0 0 2 2 0 0 3 3 3 0 4 4 4 4 5 5 5 5 6 6 6 0 7 7 0 0 8 0 0 0 This operation is very time-sensitive in my code as it has to be done often and with varying vector/matrix sizes. Therefore I would like to avoid a loop if at all possible. Any ideas would be greatly appreciated.
|
Pages: 1 Prev: Reading from Csv File Next: transform vector in matrix with more elements |