In Octave, I have a vector with indexes e.g. a = [ 1 2 3 1 2 3]
. I now want a matrix m = zeros(size(a,2), max(a))
to have ones depending on vector a:
m =
[1 0 0
0 1 0
0 0 1
1 0 0
0 1 0
0 0 1]
How do I do that?
I tried this, but it didn't work: m(a,:) = 1;