File Exchange

image thumbnail

Draw a circle.

version (1.45 KB) by Zhihua He
Easy circle drawing.


Updated 06 Oct 2011

View Version History

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week Popular File 2010 2011

Just give the center, the radius and the number of points. You can even define simple styles.

Cite As

Zhihua He (2021). Draw a circle. (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (63)

Laila Ibraheem

Chad Greene

Geoff: The functionality you seek is available in circles.m, which is described here:


Geoff Stanley

Slightly easier than
hc = circle(...);
set(hc, 'Property', value)

would be to change, in circle.m, the 'style' argument to 'varargin', and pass all those additional arguments straight to plot, ie.




A++ Will code again!!


Jason Zhang

Matlab's built-in "rectangle" command to draw circles
function circle (x,y,radius,varargin)

rectangle('position',[x-radius, y-radius, 2*radius, 2*radius],'curvature',[1 1],varargin{:});

Jason Riesbeck

Maosong ?

no so good, did not consider the scale between x and y

nuaa lilin

very good!


Sorry, I see the point - you want to close the circle. Duh.


Broken; produces repeated coordinate at the start and end position, so the centroid of the points is not the centre of the circle.


Good solution,

julian rojas

Klaus Hansen

Muhammad Ahsan

Must work with the specified starting and the ending angle.

Joe Daady

Ricardo Peligroso

Excellent function, couldn't believe that there wasn't a simple in-built one! Thank you! :)

eyap candir

a missing function for matlab thanks to author

Jao Tao Mao Ying Ling Ping Golf

Don't eat carrots.

tom tomo

Jens H.

t = linspace(0, 2*pi, Number_of_points);
also works well!

sam s


Thang you sir
From thailand

mohammad t moravej

nice usage of the pol2cart command.
if one is to use rectangle command to draw a circle,it should be noticed that the axis aspect ratios also should be set to equal ratiots or the circle plot will seem an ellipse.(use daspect([1 1 1])

lila naseri

Joerg Buchholz

Matlab's built-in "rectangle" command can draw circles if you use the curvature parameter:

rectangle ('position', [0, 0, 1, 1], curvature', [1, 1])

mahmoud fawzi

very helpful

Allan Ye

Thanks, it's the one I'm after.

Hendro Nurhadi

THANKS!!!!!! :-)

ahmed safie


Konstantinos Michalakis


Yasar Becerikli

Alev Soke

I am thankful for you.

Sven Mensing

Just what you need. Works perfectly

PRE Adrien

Great Work !
it just do the job, and well !

Georges Aoude

Very Useful

LI Jia

easy to use, thanks

Alessio Perani

Useful and functional.

Nancy Wong

short but elegent

asdasdf asdfasdf


hirogatsu mifune


Tom Haylo

Very simple, but very good!

F Aries

works for me too!!!
Gee Thanx.

Daphne Weihs

A realy nice little basis for more complex things

Nick Cheilakos

James J. Cai

It works!!

shankar kumar selvaraja


Sanith Wijesinghe


Bob Chen

Joel Sander

Exactly what I was looking for...

John G.

Liu Jerry

Very Good function!
Many many thanks.

Ramanathan Subramanian

Daniel K.


Fahad Al Mahmood

Simple ... yet very smart and useful! Thanks!

beno hwang

thumbs up!

phill t


J Kile

Easy to use, does exactly what is stated

MATLAB Release Compatibility
Created with R12.1
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!