drawCircle example

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

drawCircle example

COhio
Hello,  
  I am a beginner with Octave.  
  I have successfully installed and loaded the geometry package, but I don't know how to draw a simple circle in an effort to review unit circle.  Can someone provide me with an example.  I know I'm missing a fundamental concept too.
Here is what I've tried so far.
>> h = drawCircle(x0,y0,1);
error: 'x0' undefined near line 1 column 16
>> pkg load geometry
>> h = drawCircle(x0,y0,1);
error: 'x0' undefined near line 1 column 16

  I've also tried the symbolic package.

I'm an aspiring middle school math teacher and like Octave because it can visualize so much, but it is hard to learn.  So, any help is much appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: drawCircle example

nrjank
On Thu, May 25, 2017 at 1:14 AM, COhio <[hidden email]> wrote:
Hello,
  I am a beginner with Octave.
  I have successfully installed and loaded the geometry package, but I don't
know how to draw a simple circle in an effort to review unit circle.  Can
someone provide me with an example.  I know I'm missing a fundamental
concept too.
Here is what I've tried so far.
>> h = drawCircle(x0,y0,1);
error: 'x0' undefined near line 1 column 16
>> pkg load geometry
>> h = drawCircle(x0,y0,1);
error: 'x0' undefined near line 1 column 16

  I've also tried the symbolic package.

I'm an aspiring middle school math teacher and like Octave because it can
visualize so much, but it is hard to learn.  So, any help is much
appreciated.



Octave is a numerical language, not a general algebra language.  so you can't use variable you haven't yet assigned values to.  x0 undefined means it doesn't exist yet and Octave doesn't know how to drawCircle() with empty information.

try defining x0 and y0 first, then try your command again.

>> x0 = 1; y0 = 2; r = 3;
>> h = drawCircle(x0, y0, r);

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: drawCircle example

Andreas Weber-6
In reply to this post by COhio
Hi COhio,

Am 25.05.2017 um 07:14 schrieb COhio:

> Hello,  
>   I am a beginner with Octave.  
>   I have successfully installed and loaded the geometry package, but I don't
> know how to draw a simple circle in an effort to review unit circle.  Can
> someone provide me with an example.  I know I'm missing a fundamental
> concept too.
> Here is what I've tried so far.
>>> pkg load geometry
>>> h = drawCircle(x0,y0,1);
> error: 'x0' undefined near line 1 column 16

It looks like you've never assigned the variable x0 or y0. Use the
editor and type in the following. Then save it as "myscript1.m" and run
it from the GUI with the "execute script" button on top of the editor or
type "myscript" in the interactive commandline:

# add to file "myscript.m"

pkg load geometry
x0 = 2;
y0 = 3;
h = drawCircle (x0, y0, 1);
grid on

# end of file

Lines beginning with # are comments and ignored by the interpreter. If
you want to evaluate an expression wit a variable, it has to been
assigned before. Or you just use constants in the function call like

drawCircle (4,5,6);

which will draw a circle around x=4, y=5 with radius=6.
I would suggest a basic tutorial to get familiar with the language.

> I'm an aspiring middle school math teacher and like Octave because it can
> visualize so much, but it is hard to learn.  So, any help is much
> appreciated.

Have you read
https://www.gnu.org/software/octave/doc/interpreter/Simple-Examples.html#Simple-Examples
?

-- Andy

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: drawCircle example

Doug Stewart-4
In reply to this post by COhio


On Thu, May 25, 2017 at 1:14 AM, COhio <[hidden email]> wrote:
Hello,
  I am a beginner with Octave.
  I have successfully installed and loaded the geometry package, but I don't
know how to draw a simple circle in an effort to review unit circle.  Can
someone provide me with an example.  I know I'm missing a fundamental
concept too.
Here is what I've tried so far.
>> h = drawCircle(x0,y0,1);
error: 'x0' undefined near line 1 column 16
>> pkg load geometry
>> h = drawCircle(x0,y0,1);
error: 'x0' undefined near line 1 column 16

  I've also tried the symbolic package.

I'm an aspiring middle school math teacher and like Octave because it can
visualize so much, but it is hard to learn.  So, any help is much
appreciated.


try this as an example


drawCircle(0,0,1)
hold on 
for k=0:5
  x=sin(k*2*pi/6)
  y=cos(k*2*pi/6)
  r=1
  drawCircle(x,y,r)
endfor

for k=0:5
  x=2*sin(k*2*pi/6)
  y=2*cos(k*2*pi/6)
  r=1
  drawCircle(x,y,r)
endfor




_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave