Search code examples
octavecomputational-geometry

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?


Solution

  • r = 1;
    center = [0, 0];
    t = linspace(0,2*pi,100)'; 
    x = r.*cos(t) + center(1); 
    y = r.*sin(t) + center(2); 
    plot(x, y);