I am working with a machine learning alogrithm and these two lines of code have helped me but I still do not understand what they do exactly, specially the last one
eye_matrix = eye(10);y_matrix = eye_matrix(y, :);
so 'y' is a vector consisting of numbers of 1 to 10 i.e: y = [1;2;3;4;5;6;7;8;9;10]
The result y matrix is a matrix with 10 rows and 10 columns, every row has zeros everywhere, but one in an index of the corresponding row value in y.
can someone how did we achieve this, and how the second line of code works.