Octave: Difference between revisions
mNo edit summary |
No edit summary |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
[[Category:Software]] {{ | [[Category:Software]] {{Draft}} | ||
[https://octave.org/ GNU Octave] is a scientific programming language that has a Powerful mathematics-oriented syntax with built-in 2D/3D plotting and visualization tools. It is free and open-source software (FOSS) and is Drop-in compatible with many [[MATLAB]] scripts. | [https://octave.org/ GNU Octave] is a scientific programming language that has a Powerful mathematics-oriented syntax with built-in 2D/3D plotting and visualization tools. It is free and open-source software (FOSS) and is Drop-in compatible with many [[MATLAB]] scripts. | ||
== Running Octave code == | == Running Octave code == | ||
Consider the following example code: | |||
{{File | {{File | ||
|name=octave_2d_plot.m | |name=octave_2d_plot.m | ||
Line 19: | Line 19: | ||
}} | }} | ||
Here is a simple Slurm script that you can use to run <code>octave_2d_plot.m</code>: | |||
{{File | {{File | ||
|name=octave_job_1.sh | |name=octave_job_1.sh | ||
Line 32: | Line 33: | ||
octave --no-gui octave_2d_plot.m | octave --no-gui octave_2d_plot.m | ||
}} | }} | ||
Note that Octave relies on the Gnuplot package to generate plots. | |||
=== Running MATLAB code === | |||
Octave can often be used as a drop-in replacement for running MATLAB scripts, like the <code>cosplot.m</code> example on our [[MATLAB#Running_a_MATLAB_code|MATLAB]] page: | |||
{{File | |||
|name=octave_job_1.sh | |||
|lang="bash" | |||
|contents= | |||
#!/bin/bash -l | |||
#SBATCH --time=0-00:10 | |||
#SBATCH --ntasks=1 | |||
#SBATCH --cpus-per-task=1 | |||
#SBATCH --mem=4000M | |||
module load octave/5.2.0 gnuplot/5.4.2 | |||
octave --no-gui --traditional --eval "cosplot" | |||
}} | |||
== Further reading == | |||
* [https://octave.org/ GNU Octave Homepage] | |||
* [https://docs.octave.org/v5.2.0/ Documentation for GNU Octave v5.2.0] (available in StdEnv/2020) | |||
* [https://docs.octave.org/v4.2.2/ Documentation for GNU Octave v4.2.2] (available in StdEnv/2018.3) |
Latest revision as of 18:34, 15 July 2024
This is not a complete article: This is a draft, a work in progress that is intended to be published into an article, which may or may not be ready for inclusion in the main wiki. It should not necessarily be considered factual or authoritative.
GNU Octave is a scientific programming language that has a Powerful mathematics-oriented syntax with built-in 2D/3D plotting and visualization tools. It is free and open-source software (FOSS) and is Drop-in compatible with many MATLAB scripts.
Running Octave code
Consider the following example code:
x = -10:0.1:10;
y = sin (x);
plot (x, y);
title ("Simple 2-D Plot");
xlabel ("x");
ylabel ("sin (x)");
print -dpng octave_2d_plot.png
quit
Here is a simple Slurm script that you can use to run octave_2d_plot.m
:
#!/bin/bash -l
#SBATCH --time=0-00:10
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --mem=4000M
module load octave/5.2.0 gnuplot/5.4.2
octave --no-gui octave_2d_plot.m
Note that Octave relies on the Gnuplot package to generate plots.
Running MATLAB code
Octave can often be used as a drop-in replacement for running MATLAB scripts, like the cosplot.m
example on our MATLAB page:
#!/bin/bash -l
#SBATCH --time=0-00:10
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --mem=4000M
module load octave/5.2.0 gnuplot/5.4.2
octave --no-gui --traditional --eval "cosplot"
Further reading
- GNU Octave Homepage
- Documentation for GNU Octave v5.2.0 (available in StdEnv/2020)
- Documentation for GNU Octave v4.2.2 (available in StdEnv/2018.3)