Difference between revisions of "Octave"

From Coder Merlin
Line 1: Line 1:
== Octave ==
GNU Octave is software featuring a high-level programming language, primarily intended for numerical computations. Octave helps in solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with MATLAB.
== Preparation ==
In this exercise, you'll be generating graphic files by using Octave.  In order to view these files, you'll save them in a special directory called "~www" which must be created in your home directory.  The following instructions will instruct you on how to create this directory.
{{Prepare WWW Directory}}
== Graphing ==
== Graphing ==
* Be sure to execute <code>graphics_toolkit("gnuplot")</code> prior to graphing
* Be sure to execute <code>graphics_toolkit("gnuplot")</code> prior to graphing
== Examples ==
== Examples ==
=== 3-D Sombrero Plot ===
=== 3-D Sombrero Plot ===

Revision as of 15:46, 26 March 2022

Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder

Octave[edit]

GNU Octave is software featuring a high-level programming language, primarily intended for numerical computations. Octave helps in solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with MATLAB.


Preparation[edit]

In this exercise, you'll be generating graphic files by using Octave. In order to view these files, you'll save them in a special directory called "~www" which must be created in your home directory. The following instructions will instruct you on how to create this directory.

Create a directory to be served by the web server. If the directory already exists, no error will occur.

amrit-gupta@codermerlin:~$ mkdir --parents ~/www


Enter the directory.

amrit-gupta@codermerlin:~$ cd ~/www


Set the permissions so that the files can be accessed by the web server. If permission errors are encountered, re-execute this command.

amrit-gupta@codermerlin:~$ chmod -R a+rX ~/www

Graphing[edit]

  • Be sure to execute graphics_toolkit("gnuplot") prior to graphing

Examples[edit]

3-D Sombrero Plot[edit]

tx = ty = linspace (-8, 8, 41)';
[xx, yy] = meshgrid (tx, ty);
r = sqrt (xx .^ 2 + yy .^ 2) + eps;
tz = sin (r) ./ r;
mesh (tx, ty, tz);
xlabel ("tx");
ylabel ("ty");
zlabel ("tz");
title ("3-D Sombrero plot");