I am defining the matrix z this way :
z=zeros(n,m);for i=1:n for j=1:m z(i,j)= i==y(j); endend
where y is a vector of size m. Is there a better way to write this ? (one line maybe)
arraymatrixmatrix arrayvectorization
z=zeros(n,m);for i=1:n for j=1:m z(i,j)= i==y(j); endend
Best Answer