Octave Introduction

From Coder Merlin
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