01Dec
2016
Eugene / Learning, Stanford Machine Learning / 0 comment
Control Statements (Octave)
1. for i=1:10,
v(i) = 2^i;
end;
v
2. i=1;
while i<=5,
v(i) = 100;
i = i+1;
end;
v
3. i=1;
while true,
v(i) = 999;
i = i+1;
if i==7;;
break;
end;
end;
v
4. v(1) = 2;
if v(1) == 1,
disp('The value is one');
elseif v(1) == 2,
disp('The value is two');
else
disp('The value is not one or two');
end;
The value is two