Octave Introduction

From Coder Merlin
Revision as of 10:49, 21 March 2022 by David-ben-yaakov (talk | contribs) (Created page with "== Torus == 1. Enter your "www" directory: {{ConsoleLine|john-williams@codermerlin:~$ |cd ~/www }} 2. Start '''octave''': {{ConsoleLine|john-williams@codermerlin:~$ |octave }} 3. Within '''octave''', type the following to create and plot a torus, saving the file as "torus.png" to your www directory. {{ConsoleLines |classes=rounded py-2 |prompt=  | octave:1> u {{Equal}} linspace(0, 2*pi, 25); octave:2> v {{Equal}} u; octave:3> [U V] {{Equal}} meshgrid(u, v); octave:...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder

Torus[edit]

1. Enter your "www" directory:

john-williams@codermerlin:~$  cd ~/www

2. Start octave:

john-williams@codermerlin:~$  octave

3. Within octave, type the following to create and plot a torus, saving the file as "torus.png" to your www directory.

  
octave:1> u = linspace(0, 2*pi, 25);
octave:2> v = u;
octave:3> [U V] = meshgrid(u, v);

octave:4> X = (5 + cos(U)).*cos(V);
octave:5> Y = (5 + cos(U)).*sin(V);
octave:6> Z = sin(U);

octave:7> surf(X, Y, Z);
octave:8> axis('equal');

octave:9> print -dpng torus.png