I have a matrix X e.g = [a b; c d; e f].
I need to create another matrix listing the index positions and values of the matrix.
e.g. The output is E = [ 1 1 a ; 1 2 b ; 2 1 c ; 2 2 d ; 3 1 e ; 3 2 f ]
I have been trying to use a double for loop but even if it did work, that sounds like a bad idea.
So can anyone has a better idea to perform above task?
Here is the dumbest thing I could think of (Assuming that
a,b,c,d,e,fare all scalars)However, I have a feeling that there might be an answer that is more elegant.