I am trying to get binary single-axis encoding of an integer vector in Octave. I have a vector y, let's say
y = [1 ; 2 ; 3 ; 1 ; 3]
and i need a matrix
Y = [1 0 0
0 1 0
0 0 1
1 0 0
0 0 1]
I can build matrix 1 from K manually using
Y = [];
Y = [Y y == 1];
Y = [Y y == 2];
Y = [Y y == 3];
But when I try to build it with a loop for,
Y = [];
for i = unique(y),
Y = [Y y == i];
endfor
something will go wrong:
error: mx_el_eq: nonconformant arguments (op1 is 5x1, op2 is 3x1)
I donβt even understand the error message. Where is my mistake?
source
share