I have the following loop that does what I need:
> whos Y
Name Size Bytes Class Attributes
Y 10x5000 400000 double
> whos y
Name Size Bytes Class Attributes
y 5000x1 40000 double
Y = zeros(K,m);
for i=1:m
Y(y(i),i)=1;
end
I would like to vectorize it and I have tried without success e.g.
Y = zeros(K,m);
Y(y,:)=1;
The idea is to get a vector of:
y = [9, 8, 7, .. etc]
and convert it to:
Y = [[0 0 0 0 0 0 0 0 1 0]' [0 0 0 0 0 0 0 1 0 0]' [0 0 0 0 0 0 1 0 0 0]' ... etc]
this I need in the context of a multi-class ANN implementation.