Difference between revisions of "Octave"
(→Editor) |
|||
(16 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Software]] | [[Category:Software]] | ||
[[Category:IDEs]] | [[Category:IDEs]] | ||
− | [[Category: | + | [[Category:Frameworks]] |
− | Octave is an open source MATLAB-like application. More information can be found at the [https://www.gnu.org/software/octave/ Octave website]. | + | [[Category:Numerical Computing]] |
− | + | Octave is an open source, MATLAB-like, numerical computing application (see [[:Category:Numerical Computing]]). 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] | ||
* Installation on [https://wiki.octave.org/Octave_for_Microsoft_Windows Windows] | * Installation on [https://wiki.octave.org/Octave_for_Microsoft_Windows Windows] | ||
* 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. | ||
+ | |||
+ | 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)]] | ||
+ | |||
+ | == 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. | ||
+ | |||
+ | 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. | ||
+ | |||
+ | == Editor == | ||
+ | The editor is where you can create your own scripts. To run your script, you can press the F5 key. | ||
+ | |||
+ | === Changing the editor === | ||
+ | In OCTAVE you can type the edit command in order to open up the default editor. Generally, this editor is emacs - which many people don't like. How do you change the editor that opens when you type in edit at the command line? | ||
+ | |||
+ | For me, it doesn't seem to work if I type in something like EDITOR("gedit") at the Octave command line to override the default of loading emacs with loading up the more friendly gedit instead. If I do this EDITOR command and later type in edit test.m, then it still uses emacs. | ||
+ | |||
+ | So what I do instead is run the command system("gedit test.m") to open the file. You could write an .m file, e.g. called myed.m, to which you pass a parameter of the filename to edit, and it simply calls the above system command to edit the given filename. | ||
+ | |||
+ | If anyone has a better solution, please post it to this thread. | ||
+ | |||
+ | |||
+ | === 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 are in that location in the IDE.</li> | ||
+ | </ol> | ||
+ | |||
+ | = Packages = | ||
+ | [https://octave.sourceforge.io/ Octave Forge] allows you to install packages to use within Octave. For a more in-depth description of forge and Octave packages, visit the [https://wiki.octave.org/Category:Octave_Forge Octave Forge Wiki]. | ||
+ | |||
+ | ; pkg list : Lists installed packages | ||
+ | ; pkg install -forge <pkg-name> : Install a package | ||
+ | ; pkg load <pkg-name> : loads a package in to the current Octave session | ||
+ | |||
+ | == Useful Packages == | ||
+ | The following is a list of packages considered useful by staff, students and researchers: | ||
+ | ; communications : [https://wiki.octave.org/Communications_package The communications package] provides digital communications functions for use with Octave. The functions provided by the communications package include creation of signals and noise, channel modeling and equalization, block and convolutional coding, and modulation and demodulation. | ||
+ | ; control : [https://wiki.octave.org/Control_package The control package] provides Computer-Aided Control System Design (CACSD) Tools for GNU Octave, based on the proven SLICOT Library. | ||
+ | ; image : [https://wiki.octave.org/Image_package The Octave-forge Image package] provides functions for processing images. The package also provides functions for feature extraction, image statistics, spatial and geometric transformations, morphological operations, linear filtering, and much more. | ||
+ | ; mexopencv : [http://kyamagu.github.io/mexopencv/ This mexopencv package] provides matlab mex functions that interface a hundred of OpenCV APIs. | ||
+ | ; parallel : [https://wiki.octave.org/Parallel_package The Parallel execution package] provides utilities to work with clusters, but also functions to parallelize work among cores of a single machine. Note that there may be some issues with this package on Windows. | ||
+ | ; signal : [https://wiki.octave.org/Signal_package The signal package] provides signal processing algorithms for use with Octave. The functions provided by the signal package include creation of waveforms, FIR and IIR filter design, spectral analysis, Fourier and other transforms, window functions, and resampling and rate changing. There are also some wavelet functions included, because there is no separate wavelet package, at least for now. | ||
+ | ; sockets : [https://wiki.octave.org/Sockets_package The Sockets Package] can be used to communicate over network with TCP/IP. |
Latest revision as of 07:33, 9 June 2020
Octave is an open source, MATLAB-like, numerical computing application (see Category:Numerical Computing). More information can be found at the Octave website.
Contents
Installation[edit]
- 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[edit]
Path[edit]
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[edit]
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[edit]
The editor is where you can create your own scripts. To run your script, you can press the F5 key.
Changing the editor[edit]
In OCTAVE you can type the edit command in order to open up the default editor. Generally, this editor is emacs - which many people don't like. How do you change the editor that opens when you type in edit at the command line?
For me, it doesn't seem to work if I type in something like EDITOR("gedit") at the Octave command line to override the default of loading emacs with loading up the more friendly gedit instead. If I do this EDITOR command and later type in edit test.m, then it still uses emacs.
So what I do instead is run the command system("gedit test.m") to open the file. You could write an .m file, e.g. called myed.m, to which you pass a parameter of the filename to edit, and it simply calls the above system command to edit the given filename.
If anyone has a better solution, please post it to this thread.
Writing Functions[edit]
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 are in that location in the IDE.
Packages[edit]
Octave Forge allows you to install packages to use within Octave. For a more in-depth description of forge and Octave packages, visit the Octave Forge Wiki.
- pkg list
- Lists installed packages
- pkg install -forge <pkg-name>
- Install a package
- pkg load <pkg-name>
- loads a package in to the current Octave session
Useful Packages[edit]
The following is a list of packages considered useful by staff, students and researchers:
- communications
- The communications package provides digital communications functions for use with Octave. The functions provided by the communications package include creation of signals and noise, channel modeling and equalization, block and convolutional coding, and modulation and demodulation.
- control
- The control package provides Computer-Aided Control System Design (CACSD) Tools for GNU Octave, based on the proven SLICOT Library.
- image
- The Octave-forge Image package provides functions for processing images. The package also provides functions for feature extraction, image statistics, spatial and geometric transformations, morphological operations, linear filtering, and much more.
- mexopencv
- This mexopencv package provides matlab mex functions that interface a hundred of OpenCV APIs.
- parallel
- The Parallel execution package provides utilities to work with clusters, but also functions to parallelize work among cores of a single machine. Note that there may be some issues with this package on Windows.
- signal
- The signal package provides signal processing algorithms for use with Octave. The functions provided by the signal package include creation of waveforms, FIR and IIR filter design, spectral analysis, Fourier and other transforms, window functions, and resampling and rate changing. There are also some wavelet functions included, because there is no separate wavelet package, at least for now.
- sockets
- The Sockets Package can be used to communicate over network with TCP/IP.