MATLAB: Function that returns an NxN matrix

identity matrices

I need to create a function that when a value for N is entered it returns an NxN identity matrix. But this needs to be done without employing Matlab commands which operate on entire matrices, rows, and columns.

Best Answer

for jj = N:-1:1
out(jj,jj) = 1;
end