Write a short comment explaining the code:
function DrawCircle(a, b, r)
%DRAWCIRCLE draws a circle on the coordinate plane
% a and b are the x-axis and y-axis coordinates of the center
% of the circle and r is its radius
t = 0:pi/180:2*pi;
x = r*cos(t) + a;
y = r*sin(t) + b;
plot(x, y, '-', a, b, '.');
axis equal
axis padded
text(a, b,'\leftarrow center')
title("The circle of radius " + string(r));
xlabel("X");
ylabel("Y")
end
function DrawCircle(a, b, r)
%DRAWCIRCLE draws a circle on the coordinate plane
% a and b are the x-axis and y-axis coordinates of the center
% of the circle and r is its radius
%create array of parameters from 0 to 2pi with step pi/180
t = 0:pi/180:2*pi;
% calculate x and y coordinates for each t
x = r*cos(t) + a;
y = r*sin(t) + b;
% plot y vs x
plot(x, y, '-', a, b, '.');
% format graph
axis equal
axis padded
text(a, b,'\leftarrow center')
title("The circle of radius " + string(r));
xlabel("X");
ylabel("Y")
end
Comments
Leave a comment