I have a y of size 5000,1 (matrix), which contains integers between 1 and 10. I want to expand those indices into a 1-of-10 vector. I.e., y contains 1,2,3... and I want it t
I think you mean:
y = [2 5 7]; Y = zeros(5000,10); Y(:,y) = 1;
After the question edit, it should be this instead:
y = [2,5,7,9,1,4,5,7,8,9....]; //(size (1,5000)) for i = 1:5000 Y(i,y(i)) = 1; end