Graphics Programs Reference
In-Depth Information
the idea is to fill the largest circle in black, then fill the next largest circle in
white leaving only a ring of black, then fill the next largest circle in black
leaving a ring of white, etc. The if statement tests true when r is odd and
false when it is even. We stop the alternation of black and white at a radius
of 2 to make the last circle red instead of black; then we adjust the axes to
make the circles appear round.
t = linspace(0, 2*pi, 100);
cla reset; hold on
for r = 21:-1:2
if mod(r, 2)
fill(r*cos(t), r*sin(t), 'k')
else
fill(r*cos(t), r*sin(t), 'w')
end
end
fill(cos(t), sin(t), 'r')
axis equal; hold off
20
15
10
5
0
5
10
15
20
25
20
15
10
5
0
5
10
15
20
25
Problem 6
Here are the contents of our solution M-file:
function m = mylcm(varargin)
nums = [varargin { : } ];
if ~ isnumeric(nums) any(nums ~ = round(real(nums))) ...
any(nums <= 0)
 
Search WWH ::




Custom Search