MATLAB: Why elseif (i==1) && j==m condition went unexecuted

elseif

A=zeros(12,1);
n=3;
m=4;
for i=1:n
for j=1:m
if i==1 && j==m
A(1,1)=1;
elseif (i==1) && (j>1 || j<m)
A(2,1)=2;
elseif (i==1) && (j==m)
A(3,1)=3;
end
A

Best Answer

The condition "i==1 && j==m" appears twice:
if i==1 && j==m % First time
A(1,1)=1;
elseif (i==1) && (j>1 || j<m)
A(2,1)=2;
elseif (i==1) && (j==m) % Second time
A(3,1)=3;
end
If the first condition is met already, further elseif branches are not called anymore. The if block is left directly after the first condition is matching and the corresponding block was executed.