Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw a circle in GNU Octave

In Matlab you can draw a circle by just specifying the center and the radius like this:

R = 10;
Center = [5,8];
circle(Center,R,1000,'b-');
hold on
plot(Center(1),Center(2),'g.')

The same code for MatLab won't work for GNU Octave. What octave code would draw a circle given a center x,y coordinates and a radius?

like image 732
simpatico Avatar asked Nov 01 '11 19:11

simpatico


People also ask

How do I plot a circle in R?

There is no direct function in R to draw a circle but we can make use of plotrix package for this purpose. The plotrix package has a function called draw. cirlce which is can be used to draw a circle but we first need to draw a plot in base R then pass the correct arguments in draw. circle.


1 Answers

t = linspace(0,2*pi,100)'; 
circsx = r.*cos(t) + x; 
circsy = r.*sin(t) + y; 
plot(circsx,circsy); 
like image 188
BenH Avatar answered Sep 18 '22 12:09

BenH