Script sequence_for_if.m
Download Script sequence_for_if.m
b=[-5 3 6;3 6 -5;6 -5 3];
for k=1:3
a=b(k,:)

for i=1:3

if a(i) < 0;
disp('a is negative');
step1=1;
check=[step1 a(i)]

elseif rem(a(i),2) == 0;
disp('a is positive and even');
A1 = a(i)/2;
step2=2;
check=[step2 a(i)]

else
A2 = (a(i)+1)/2;
disp('a is positive and odd')
step3=3;
check=[step3 a(i)]

end

end

end
Back