
319Appendix A
A.6 Programming
The if-else statement can be demonstrated through the following example.
>> for i = 1:6
x = rand(1);
if x<0.5
disp('x is less than 0.5')
else
disp('x is greater than 0.5')
end
end
Note that the rst end is the end of the if statement and the second end
is the end of the for loop. Note that when a semicolon is put at the end of
a statement, it suppresses printing of the variable. The following output is
displayed by running the above code.
x is greater than 0.5
x is greater than 0.5
x is less than 0.5
x is greater than 0.5
x is greater than 0.5
x is less than 0.5
Figure A.3
Contour plot.