Plot a circle on a 2D grid

7 Ansichten (letzte 30 Tage)
Marco Rocchini
Marco Rocchini am 26 Mai 2014
Beantwortet: Geoff Hayes am 26 Mai 2014
Hi everybody, I would like to plot a circle on a 2D grid. Any advises? Many thanks

Antworten (1)

Geoff Hayes
Geoff Hayes am 26 Mai 2014
Please see the MATLAB Wiki entry http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F for several options on drawing circles.
Or you could create three identically sized vectors: the first being the points along the x-axis:
x = (-r:d:r)';
where r is the radius of the circle and d is the step size. The next vector is just the upper half of the circle according to the equation of the circle:
cu = sqrt(r^2 - x.^2);
And the third vector is just the lower half of the circle:
cl = -cu;
You can then apply "shifts" to the data to get the circle centred at coordinate (h,k), and then just plot both halves of the circle.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by