Difference between revisions of "Octave"
Kynikos.bot (Talk | contribs) (Template:i18n is deprecated, use interlanguage links, see Help talk:I18n#"Dummy" interlanguage links and deprecation of Template:i18n) |
(added some info about plotting backends and GUIs and more about Octave-Forge. rewrote a lot of things.) |
||
Line 1: | Line 1: | ||
[[Category:Mathematics and science]] | [[Category:Mathematics and science]] | ||
− | [[Wikipedia:GNU_Octave|Octave]] is a high-level language, primarily intended for numerical computations | + | [[Wikipedia:GNU_Octave|Octave]] is a high-level language, primarily intended for numerical computations. |
+ | From the [http://www.gnu.org/software/octave/ official website]: | ||
+ | |||
+ | :''GNU Octave is a high-level interpreted language, primarily intended for numerical computations. It provides capabilities for the numerical solution of linear and nonlinear problems, and for performing other numerical experiments. It also provides extensive graphics capabilities for data visualization and manipulation. Octave is normally used through its interactive command line interface, but it can also be used to write non-interactive programs. The Octave language is quite similar to Matlab so that most programs are easily portable.'' | ||
== Installation == | == Installation == | ||
+ | Octave can be [[Pacman|installed]] with the package {{Pkg|octave}}, available in the [[official repositories]]. | ||
− | + | == Octave-Forge == | |
− | + | Extra packages for GNU Octave can be found in [http://octave.sourceforge.net/index.html Octave-Forge]. They are comparable to toolboxes in Matlab. Some may be found in [[AUR]] (a non-exhaustive list): | |
+ | * {{App|Image|Provides functions for processing images.|http://octave.sourceforge.net/image/index.html|{{AUR|octave-image}}}} | ||
+ | * {{App|Statistics|Provides additional statistical functions.|http://octave.sourceforge.net/statistics/index.html|{{AUR|octave-statistics}}}} | ||
+ | * {{App|IO|Provides input and output in external formats such as XML, CSV or XLS.|http://octave.sourceforge.net/io/index.html|{{AUR|octave-io}}}} | ||
+ | * {{App|Signal|Provides functions for processing images|http://octave.sourceforge.net/image/index.html|{{AUR|octave-signal}}}} | ||
+ | * {{App|Multicore|Provides functions for parallel processing on multiple cores.|http://octave.sourceforge.net/multicore/index.html|{{AUR|octave-multicore}}}} | ||
− | + | A complete list can be found on [http://octave.sourceforge.net/packages.php Octave-Forge]. For packages that do not exist on the [[AUR]] the following steps need to be followed : | |
− | For | + | |
− | + | # Download the {{ic|.tar.gz}} package from Octave-Forge. | |
+ | # Install it from Octave as user by executing: | ||
− | + | octave:1> pkg install package_file_name.tar.gz | |
− | + | Packages have dependencies which you have to install before installing your package, if you want to bypass this use: | |
− | === | + | octave:1> pkg install -no-deps package_file_name.tar.gz |
+ | |||
+ | To uninstall a package: | ||
+ | |||
+ | octave:1> pkg uninstall package_file_name.tar.gz | ||
+ | |||
+ | Some packages get loaded automatically by Octave, for those which do not: | ||
+ | |||
+ | octave:1> pkg load package_name | ||
+ | |||
+ | or | ||
+ | |||
+ | octave:1> pkg load all | ||
+ | |||
+ | To see which packages have been loaded use {{ic|pkg list}}, the packages with an asterisk are the ones that are already loaded. | ||
+ | |||
+ | == Plotting == | ||
+ | |||
+ | Octave has two official plotting backends: | ||
+ | * [http://www.gnuplot.info/ GnuPlot]: The classic plotting utility. | ||
+ | * FLTK: A new experimental OpenGL backend based on the {{Pkg|fltk}} GUI toolkit. | ||
+ | |||
+ | GnuPlot is still the default, but it can be changed by: | ||
+ | |||
+ | octave:1> graphics_toolkit("fltk"); | ||
+ | |||
+ | To make this change permanent add it to your {{ic|~/.octaverc}} file. | ||
+ | |||
+ | == Graphical interfaces == | ||
+ | |||
+ | There are very few graphical interfaces for Octave and none of them are official: | ||
+ | * {{App|Cantor|A graphical user interface that delegates its mathematical operations to one of several back ends (Scilab, Maxima, Octave and others)|http://edu.kde.org/cantor/|{{Pkg|kdeedu-cantor}}}} | ||
+ | * {{App|QtOctave|A Qt frontend for Octave|https://forja.rediris.es/projects/csl-qtoctave/|{{AUR|qtoctave}}}} | ||
+ | |||
+ | == Reading Microsoft Excel Spreadsheets == | ||
There are several ways to read Microsoft Excel files with Octave. | There are several ways to read Microsoft Excel files with Octave. | ||
− | ==== Converting | + | ==== Converting to an open format ==== |
− | + | The easiest way to use {{ic|.xls}} files in Octave would be to convert them to {{ic|.csv}} or {{ic|.ods}} using Calc (limited to 1024 columns) from [[Libreoffice]] or [http://www.calligra.org/sheets/ Sheets](limited to 32768 columns) from the the [http://www.calligra-suite.org/ Calligra Suite]. | |
− | + | ||
− | + | ||
− | + | ||
− | + | After the conversion is complete you can use the build-in Octave function {{ic|csvread}} for {{ic|.csv}} files: | |
− | + | ||
+ | octave:1> csvread('myfile.csv'); | ||
− | + | For {{ic|.ods}} files the {{AUR|octave-io}} package is necessary which contains the {{ic|odsread}} function: | |
− | + | octave:1> odsread('myfile.ods'); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | octave: | + | For {{ic|.xlsx}} files you can use the {{AUR|xlsx2csv}} package from [[AUR]]: |
+ | |||
+ | xlsx2csv -t /path/to/save/location -x /path/to/myfile.xlsx | ||
+ | |||
+ | ==== Reading xls files directly from Octave ==== | ||
+ | |||
+ | If converting to {{ic|.csv}} or {{ic|.ods}} is not an option or does not work for whatever reason, Octave is able to read {{ic|.xls}} files using {{AUR|octave-io}} package which contains the function {{ic|xlsread}}. | ||
+ | |||
+ | The {{ic|xlsread}} requires some [[Java]] libraries as the support for XLS files is not built-in. The steps necessary to make it work are: | ||
+ | :1. [[Pacman|Install]] {{Pkg|jdk7-openjdk}}, available in the [[official repositories]]. | ||
+ | |||
+ | :A common problem is that Octave cannot find the Java libraries properly. To fix this execute the following commands in your shell: | ||
+ | |||
+ | $ export JAVA_HOME=/usr/lib/jvm/java-7-openjdk | ||
+ | $ export PATH=$PATH:$JAVA_HOME | ||
+ | |||
+ | :2. Install a Java XLS library for {{ic|xlsread}}. A comparison of the available interfaces can be found at [http://octave.org/wiki/index.php?title=IO_package#Comparison_of_interfaces_.26_usage this link], with the recommended variant {{AUR|apache-poi}} that can be found in the [[AUR]]. | ||
+ | |||
+ | :3. Finally, install the {{AUR|octave-java}} package from [[AUR]]. | ||
+ | |||
+ | To check if Java is working correctly in Octave, see the output of: | ||
+ | |||
+ | octave:1> javaclasspath | ||
STATIC JAVA PATH | STATIC JAVA PATH | ||
- empty - | - empty - | ||
Line 49: | Line 104: | ||
- empty - | - empty - | ||
− | + | To load the selected library in Octave, check if it is in the Java path. If not: | |
+ | octave:1> javaaddpath path/to/file.jar | ||
+ | (should be {{ic|/usr/share/java/apache-poi/poi-3.x.jar}} and {{ic|/usr/share/java/apache-poi/poi-ooxml-3.x.jar}}). | ||
− | |||
− | |||
− | |||
− | |||
To check if it works | To check if it works | ||
− | octave: | + | octave:1> chk_spreadsheet_support |
− | + | ||
+ | The output should be > 0: | ||
0 No spreadsheet I/O support found | 0 No spreadsheet I/O support found | ||
---------- XLS (Excel) interfaces: ---------- | ---------- XLS (Excel) interfaces: ---------- | ||
Line 71: | Line 125: | ||
128 = UNO (Java / UNO bridge - OpenOffice.org) | 128 = UNO (Java / UNO bridge - OpenOffice.org) | ||
− | + | To make this permanent add the {{ic|javaaddpath}} commands to your {{ic|~/.octaverc}} file. | |
− | + | ||
− | + |
Revision as of 16:57, 1 August 2012
Octave is a high-level language, primarily intended for numerical computations. From the official website:
- GNU Octave is a high-level interpreted language, primarily intended for numerical computations. It provides capabilities for the numerical solution of linear and nonlinear problems, and for performing other numerical experiments. It also provides extensive graphics capabilities for data visualization and manipulation. Octave is normally used through its interactive command line interface, but it can also be used to write non-interactive programs. The Octave language is quite similar to Matlab so that most programs are easily portable.
Contents
Installation
Octave can be installed with the package octave, available in the official repositories.
Octave-Forge
Extra packages for GNU Octave can be found in Octave-Forge. They are comparable to toolboxes in Matlab. Some may be found in AUR (a non-exhaustive list):
- Image — Provides functions for processing images.
- Statistics — Provides additional statistical functions.
- IO — Provides input and output in external formats such as XML, CSV or XLS.
- Signal — Provides functions for processing images
- Multicore — Provides functions for parallel processing on multiple cores.
A complete list can be found on Octave-Forge. For packages that do not exist on the AUR the following steps need to be followed :
- Download the
.tar.gz
package from Octave-Forge. - Install it from Octave as user by executing:
octave:1> pkg install package_file_name.tar.gz
Packages have dependencies which you have to install before installing your package, if you want to bypass this use:
octave:1> pkg install -no-deps package_file_name.tar.gz
To uninstall a package:
octave:1> pkg uninstall package_file_name.tar.gz
Some packages get loaded automatically by Octave, for those which do not:
octave:1> pkg load package_name
or
octave:1> pkg load all
To see which packages have been loaded use pkg list
, the packages with an asterisk are the ones that are already loaded.
Plotting
Octave has two official plotting backends:
- GnuPlot: The classic plotting utility.
- FLTK: A new experimental OpenGL backend based on the fltk GUI toolkit.
GnuPlot is still the default, but it can be changed by:
octave:1> graphics_toolkit("fltk");
To make this change permanent add it to your ~/.octaverc
file.
Graphical interfaces
There are very few graphical interfaces for Octave and none of them are official:
- Cantor — A graphical user interface that delegates its mathematical operations to one of several back ends (Scilab, Maxima, Octave and others)
- QtOctave — A Qt frontend for Octave
Reading Microsoft Excel Spreadsheets
There are several ways to read Microsoft Excel files with Octave.
Converting to an open format
The easiest way to use .xls
files in Octave would be to convert them to .csv
or .ods
using Calc (limited to 1024 columns) from Libreoffice or Sheets(limited to 32768 columns) from the the Calligra Suite.
After the conversion is complete you can use the build-in Octave function csvread
for .csv
files:
octave:1> csvread('myfile.csv');
For .ods
files the octave-io^{AUR} package is necessary which contains the odsread
function:
octave:1> odsread('myfile.ods');
For .xlsx
files you can use the xlsx2csv^{AUR} package from AUR:
xlsx2csv -t /path/to/save/location -x /path/to/myfile.xlsx
Reading xls files directly from Octave
If converting to .csv
or .ods
is not an option or does not work for whatever reason, Octave is able to read .xls
files using octave-io^{AUR} package which contains the function xlsread
.
The xlsread
requires some Java libraries as the support for XLS files is not built-in. The steps necessary to make it work are:
- 1. Install jdk7-openjdk, available in the official repositories.
- A common problem is that Octave cannot find the Java libraries properly. To fix this execute the following commands in your shell:
$ export JAVA_HOME=/usr/lib/jvm/java-7-openjdk $ export PATH=$PATH:$JAVA_HOME
- 2. Install a Java XLS library for
xlsread
. A comparison of the available interfaces can be found at this link, with the recommended variant apache-poi^{AUR} that can be found in the AUR.
- 3. Finally, install the octave-java^{AUR} package from AUR.
To check if Java is working correctly in Octave, see the output of:
octave:1> javaclasspath STATIC JAVA PATH - empty - DYNAMIC JAVA PATH - empty -
To load the selected library in Octave, check if it is in the Java path. If not:
octave:1> javaaddpath path/to/file.jar
(should be /usr/share/java/apache-poi/poi-3.x.jar
and /usr/share/java/apache-poi/poi-ooxml-3.x.jar
).
To check if it works
octave:1> chk_spreadsheet_support
The output should be > 0:
0 No spreadsheet I/O support found ---------- XLS (Excel) interfaces: ---------- 1 = COM (ActiveX / Excel) 2 = POI (Java / Apache POI) 4 = POI+OOXML (Java / Apache POI) 8 = JXL (Java / JExcelAPI) 16 = OXS (Java / OpenXLS) --- ODS (OpenOffice.org Calc) interfaces ---- 32 = OTK (Java/ ODF Toolkit) 64 = JOD (Java / jOpenDocument) ----------------- XLS & ODS: ---------------- 128 = UNO (Java / UNO bridge - OpenOffice.org)
To make this permanent add the javaaddpath
commands to your ~/.octaverc
file.