Can anyone help me with this. I am trying to construct a matrix in matlab using if, elseif and else but it does not work for me. If I skip the last else everything works correctly but if I run everything, including the last else sentence, elseif N==L(i)
and elseif N==R(i)
does not work. So if I skip the last else sentence if N==1
, elseif N>=2 && N<=4
, elseif N>=5 && N<=9
, elseif N==L(i)
and elseif R==L(i)
runs correctly but if I run everything elseif N==L(i)
and elseif R==L(i)
does not work.
N = 72;
M = 72;
adj = zeros(N,M)
L = [10:7:M-13]
R = [16:7:M-7]
for N = 1:M
for i = 1:ceil((M-10)/15)
if N==1
adj(1,2:4)= 1
elseif N>=2 && N<=4
adj(N,(N+3))=1
adj(N,(N+4))=1
adj(N,(N+5))=1
elseif N>=5 && N<=9
adj(N,(N+5))=1
adj(N,(N+6))=1
adj(N,(N+7))=1
elseif N==L(i)
adj(N,N+7)=1
adj(N,N+8)=1
elseif N==R(i)
adj(N,N+6)=1
adj(N,N+7)=1
else
adj(N,N+6)=1
adj(N,N+7)=1
adj(N,N+8)=1
end
end
end