Is there any inline command to generate shifted identity matrix in MATLAB?
A=[ ... 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 1, 0, 0
Here is Another Alternative: (little similar to bsxfun Approach by Divakar)
bsxfun
n=10; shift = 1; c = repmat(1-shift:n-shift,n,1,1); r = repmat((1:n).',1,n,1); out = r == c
This could also be a one-liner:
out = repmat((1:n).',1,n,1) == repmat(1-shift:n-shift,n,1,1)