Difference between revisions of "Octave"
m (Fixed error in URL and description of octave-signal) |
(→Reading xls files directly from Octave) |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 16: | Line 16: | ||
== Octave-Forge == | == Octave-Forge == | ||
− | Octave provides a set of packages, similar to Matlab's Toolboxes, through [http://octave.sourceforge.net/index.html Octave-Forge]. | + | Octave provides a set of packages, similar to Matlab's Toolboxes, through [http://octave.sourceforge.net/index.html Octave-Forge]. The complete list of packages is [http://octave.sourceforge.net/packages.php here]. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Packages can be installed directly in Octave, or from the AUR. See below. | |
− | |||
− | |||
− | |||
− | |||
=== Using Octave's installer === | === Using Octave's installer === | ||
− | Packages can also be managed using Octave's installer. To install a package | + | Packages can also be managed using Octave's installer. They are installed to ~/octave, or in a system directory with the -global option. To install a package: |
− | |||
− | |||
− | |||
− | octave:1> pkg install | + | octave:1> pkg install -forge packagename |
− | |||
− | |||
− | |||
− | |||
To uninstall a package: | To uninstall a package: | ||
− | octave:3> pkg uninstall packagename | + | octave:3> pkg uninstall packagename |
Some packages get loaded automatically by Octave, for those which do not: | Some packages get loaded automatically by Octave, for those which do not: | ||
Line 55: | Line 39: | ||
To see which packages have been loaded use {{ic|pkg list}}, the packages with an asterisk are the ones that are already loaded. | To see which packages have been loaded use {{ic|pkg list}}, the packages with an asterisk are the ones that are already loaded. | ||
+ | |||
+ | |||
+ | A way to make sure that all packages gets loaded at Octave startup: | ||
+ | |||
+ | {{hc|/usr/share/octave/site/m/startup/octaverc| | ||
+ | ## System-wide startup file for Octave. | ||
+ | ## | ||
+ | ## This file should contain any commands that should be executed each | ||
+ | ## time Octave starts for every user at this site. | ||
+ | pkg load all}} | ||
+ | |||
+ | === Using the AUR === | ||
+ | |||
+ | Some packages may be found in the AUR ([https://aur.archlinux.org/packages.php?O=0&K=octave-&do_Search=Go search packages]). New Octave-forge packages for Arch can be created semi-automatically using the [https://github.com/drizzd/octave-forge-archlinux#readme Octave-forge helper scripts for Archlinux]. | ||
== Plotting == | == Plotting == | ||
Line 70: | Line 68: | ||
== Graphical interfaces == | == Graphical interfaces == | ||
+ | Since Octave 3.8, Octave has it's own (experimental) GUI based on QT. Unfortunately it's not in Arch Linux repos yet. So you have to build it for your own. To start the GUI, run {{ic|octave --force-gui}} | ||
− | + | The following GUIs are unofficial. | |
* {{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|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}}}} | * {{App|QtOctave|A Qt frontend for Octave.|https://forja.rediris.es/projects/csl-qtoctave/|{{AUR|qtoctave}}}} | ||
Line 99: | Line 98: | ||
If you must work with XLS files and you cannot convert them to CSV or ODS, for whatever reason, you can use the {{ic|xlsread}} function from the {{AUR|octave-io}} package. | If you must work with XLS files and you cannot convert them to CSV or ODS, for whatever reason, you can use the {{ic|xlsread}} function from the {{AUR|octave-io}} package. | ||
− | {{ | + | Since {{AUR|octave-io}} version 1.2.5., an interface called 'OCT' was added, which perform reading .xlsx (not .xls!), ods and .gnumeric without any dependencies. However, the Java-based interface still exist (special for reading .xls files and writing those file formats). |
+ | |||
+ | ===== Steps necessary to make Java Interface available ===== | ||
The steps necessary to make it work are: | The steps necessary to make it work are: | ||
Line 142: | Line 143: | ||
To make this permanent add the {{ic|javaaddpath}} commands to your {{ic|~/.octaverc}} file. | To make this permanent add the {{ic|javaaddpath}} commands to your {{ic|~/.octaverc}} file. | ||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 22:31, 6 January 2014
Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end 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
Octave provides a set of packages, similar to Matlab's Toolboxes, through Octave-Forge. The complete list of packages is here.
Packages can be installed directly in Octave, or from the AUR. See below.
Using Octave's installer
Packages can also be managed using Octave's installer. They are installed to ~/octave, or in a system directory with the -global option. To install a package:
octave:1> pkg install -forge packagename
To uninstall a package:
octave:3> pkg uninstall packagename
Some packages get loaded automatically by Octave, for those which do not:
octave:4> pkg load packagename
or
octave:5> 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.
A way to make sure that all packages gets loaded at Octave startup:
/usr/share/octave/site/m/startup/octaverc
## System-wide startup file for Octave. ## ## This file should contain any commands that should be executed each ## time Octave starts for every user at this site. pkg load all
Using the AUR
Some packages may be found in the AUR (search packages). New Octave-forge packages for Arch can be created semi-automatically using the Octave-forge helper scripts for Archlinux.
Plotting
Octave has two official plotting backends:
- Gnuplot — A classic Linux plotting utility.
- FLTK Backend — 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
Since Octave 3.8, Octave has it's own (experimental) GUI based on QT. Unfortunately it's not in Arch Linux repos yet. So you have to build it for your own. To start the GUI, run octave --force-gui
The following GUIs are unofficial.
- 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 you must work with XLS files and you cannot convert them to CSV or ODS, for whatever reason, you can use the xlsread
function from the octave-io^{AUR} package.
Since octave-io^{AUR} version 1.2.5., an interface called 'OCT' was added, which perform reading .xlsx (not .xls!), ods and .gnumeric without any dependencies. However, the Java-based interface still exist (special for reading .xls files and writing those file formats).
Steps necessary to make Java Interface available
The steps necessary to make it work are:
- 1. Install jdk7-openjdk, available in the official repositories.
$ export JAVA_HOME=/usr/lib/jvm/java-7-openjdkYou may also want to add this to your
~/.bashrc
and append it to your PATH
.- 2. Install a Java XLS library for
xlsread
. There are more such libraries available, a comparison can be found at here. The recommended library is apache-poi^{AUR}, available 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
In the case you chose apache-poi^{AUR}, the relevant JAR files can be found in /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.