MATLAB: What is the best way to execute 2 if conditions in MATLAB

MATLABvectors

assume w=[1 2 2 2]
q=[2 1 1 1]
if w(i)==1
do somehing
else
look to q(i)
if q(i)==1
do some thing
else
do somthing
end
end

Best Answer

for ii = 1:numel(w)
if (w(ii) == 1)
%stuff


else if (q(ii) == 1)
%stuff
else
%stuff
end
end
Please accept an answer if it helps you.