Here is a MATLAB function that plots a circle with radius 'r' and locates the center at the coordinates 'x' and 'y':
function h = circle(x,y,r)
hold on
th = 0:pi/50:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
h = plot(xunit, yunit);
hold off
An alternative method is to use the 'rectangle' function:
function h = circle2(x,y,r)
d = r*2;
px = x-r;
py = y-r;
h = rectangle('Position',[px py d d],'Curvature',[1,1]);
daspect([1,1,1])
If you are using version R2012a or later and have Image Processing Toolbox, then you can use the 'viscircles' function to draw circles:
viscircles(centers,radii)
13 Comments
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_258691
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_258691
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_260374
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_260374
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_388817
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_388817
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_401575
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_401575
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_401589
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_401589
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_471988
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_471988
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_473774
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_473774
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_840148
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_840148
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_840519
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_840519
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_1223272
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_1223272
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_1223297
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_1223297
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_1226977
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_1226977
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_1227042
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/98665-how-do-i-plot-a-circle-with-a-given-radius-and-center#comment_1227042
Sign in to comment.