I just wonder whether it's possible to create an identity matrix without eye function, loop, and any matlab build in function. At first I was thinking to use something like this:
A = bsxfun(@power, 1:n, (1:n).');
Unfortunately, I do not think I can assign value '1' and '0' without using any loop. and this still use build function. any idea?
bsxfun
count as a Matlab builtin function? - Davidbsxfun
is acceptable, how aboutdiag(ones(1,n))
? - horchler