The ii
means the index in the x-axis
and the jj
means the index value in the y-axis
. This example runs over a 2x2 times one-matrix. Does Matlab have some ready commands for the index values ii
and jj
so I can avoid for-looping?
Input: trying to find a implicit solution but requires the location info (ii,jj)
h=@(a)a+ii+jj; h(ones(2))
Intented output
3 4 1+(1+1) 1+(2+1)
4 5 = 1+(1+2) 1+(2+2)
P.s. Code-smell: Explicit solution, not like this!
hh=ones(2);
for ii=1:2
for jj=1:2
hh(ii,jj)=hh(ii,jj)+ii+jj
end
end