Difference between revisions of "Octave"
(→Use) |
|||
Line 3: | Line 3: | ||
[[Category:Framework]] | [[Category:Framework]] | ||
Octave is an open source MATLAB-like application. More information can be found at the [https://www.gnu.org/software/octave/ Octave website]. | Octave is an open source MATLAB-like application. More information can be found at the [https://www.gnu.org/software/octave/ Octave website]. | ||
− | + | [[File:Octave-logo.png|thumb]] | |
= Installation = | = Installation = | ||
* Installation on [https://wiki.octave.org/Octave_for_GNU/Linux GNU/Linux] and [https://wiki.octave.org/Octave_for_other_Unix_systems Other Unix systems] | * Installation on [https://wiki.octave.org/Octave_for_GNU/Linux GNU/Linux] and [https://wiki.octave.org/Octave_for_other_Unix_systems Other Unix systems] | ||
Line 9: | Line 9: | ||
* Installation on [https://wiki.octave.org/Octave_for_macOS MacOS] | * Installation on [https://wiki.octave.org/Octave_for_macOS MacOS] | ||
− | |||
For full details on how to use Octave, visit [https://octave.org/doc/interpreter/Introduction.html An Introduction to Octave]. The [https://octave.org/doc/v4.0.1/index.html full Octave Documentation] is also available online. | For full details on how to use Octave, visit [https://octave.org/doc/interpreter/Introduction.html An Introduction to Octave]. The [https://octave.org/doc/v4.0.1/index.html full Octave Documentation] is also available online. | ||
If you're following a guide and get a "function undefined" error from a built-in function, the function may have been deprecated. For a list of deprecated functions, visit [https://octave.org/doc/interpreter/Obsolete-Functions.html Octave Obsolete Functions]. | If you're following a guide and get a "function undefined" error from a built-in function, the function may have been deprecated. For a list of deprecated functions, visit [https://octave.org/doc/interpreter/Obsolete-Functions.html Octave Obsolete Functions]. | ||
− | + | ||
+ | = The IDE = | ||
[[File:Octave IDE.png|thumb|none|The Octave IDE on Start Up (Windows)]] | [[File:Octave IDE.png|thumb|none|The Octave IDE on Start Up (Windows)]] | ||
− | + | == Path == | |
When a function is called, Octave searches a list of directories for a file that contains the function declaration. This list of directories is known as the load path. By default the load path contains a list of directories distributed with Octave plus the current working directory. To see your current load path, you can run <code>path()</code> in the Command Window. | When a function is called, Octave searches a list of directories for a file that contains the function declaration. This list of directories is known as the load path. By default the load path contains a list of directories distributed with Octave plus the current working directory. To see your current load path, you can run <code>path()</code> in the Command Window. | ||
If you are working on your own project in a separate directory, you either need to ensure Octave is in that current working directory by using the "Current Working Directory" drop down at the top left of the window, or manually add it to your path by running <code>addpath("<path>")</code> in the Command Window. | If you are working on your own project in a separate directory, you either need to ensure Octave is in that current working directory by using the "Current Working Directory" drop down at the top left of the window, or manually add it to your path by running <code>addpath("<path>")</code> in the Command Window. | ||
− | + | == Command Window == | |
The Command Window is what is usually shown on start up. Here you can call your script files that are on the path, or run some simple commands. | The Command Window is what is usually shown on start up. Here you can call your script files that are on the path, or run some simple commands. | ||
− | + | == Editor == | |
− | + | The editor is where you can create your own scripts. To run your script, you can press the F5 key. | |
− | |||
+ | === Writing Functions === | ||
+ | If you would like to create your own functions to run in other scripts or from the command window, you can run through the following steps: | ||
+ | <ol> | ||
+ | <li>Create a file <code>myfunction.m</code>, where "myfunction" is the name of the function you'd like to call.</li> | ||
+ | <li>In it, write your code, using the code below as a template: | ||
+ | <pre> | ||
+ | function result = myfunction(varA, varB) | ||
+ | # Perform any logic you'd like done | ||
+ | result = varA + varB; | ||
+ | endfunction | ||
+ | </pre></li> | ||
+ | <li> Be sure that the location of the .m file is on your path, either through adding it manually, or ensuring you </li> | ||
+ | </ol> | ||
− | + | = Packages = | |
[https://octave.sourceforge.io/ Octave Forge] allows you to install packages to use within Octave. | [https://octave.sourceforge.io/ Octave Forge] allows you to install packages to use within Octave. | ||
; pkg list : Lists installed packages | ; pkg list : Lists installed packages | ||
; pkg install -forge <pkg-name> : Install a package | ; pkg install -forge <pkg-name> : Install a package |
Revision as of 12:46, 8 February 2020
Octave is an open source MATLAB-like application. More information can be found at the Octave website.
Contents
Installation
- Installation on GNU/Linux and Other Unix systems
- Installation on Windows
- Installation on MacOS
For full details on how to use Octave, visit An Introduction to Octave. The full Octave Documentation is also available online.
If you're following a guide and get a "function undefined" error from a built-in function, the function may have been deprecated. For a list of deprecated functions, visit Octave Obsolete Functions.
The IDE
Path
When a function is called, Octave searches a list of directories for a file that contains the function declaration. This list of directories is known as the load path. By default the load path contains a list of directories distributed with Octave plus the current working directory. To see your current load path, you can run path()
in the Command Window.
If you are working on your own project in a separate directory, you either need to ensure Octave is in that current working directory by using the "Current Working Directory" drop down at the top left of the window, or manually add it to your path by running addpath("<path>")
in the Command Window.
Command Window
The Command Window is what is usually shown on start up. Here you can call your script files that are on the path, or run some simple commands.
Editor
The editor is where you can create your own scripts. To run your script, you can press the F5 key.
Writing Functions
If you would like to create your own functions to run in other scripts or from the command window, you can run through the following steps:
- Create a file
myfunction.m
, where "myfunction" is the name of the function you'd like to call. - In it, write your code, using the code below as a template:
function result = myfunction(varA, varB) # Perform any logic you'd like done result = varA + varB; endfunction
- Be sure that the location of the .m file is on your path, either through adding it manually, or ensuring you
Packages
Octave Forge allows you to install packages to use within Octave.
- pkg list
- Lists installed packages
- pkg install -forge <pkg-name>
- Install a package