For your code, you need to modify it to take more points because going from 0 to 2*pi in steps of 1 makes for a pretty chunky circle. Make it like 1000 steps with linspace(). You also need to add x center to xunit and the y center to yunit to get the center in the right place, and pass in a 1x2 vector and pass out the coordinates of the circle's perimeter.
function [xunit, yunit] = circle(xy,r)
hold on
t = linspace(0, 2*pi, 1000);
xunit = r * cos(t) + xy(1);
yunit = r * sin(t) + xy(2);
plot(xunit, yunit);
grid on;
hold off
Then you call call it like
[x, y] = circle([10, 20], 5)
Best Answer