Using Octave: Difference between revisions
Jump to navigation
Jump to search
Updated the package section to use Octave Packages instead of Forge (as forge is being deprecated
m (→Plotting: Align image as thumbnail) |
(Updated the package section to use Octave Packages instead of Forge (as forge is being deprecated) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
First, follow the [https://www.gnu.org/software/octave/doc/interpreter/Installation.html | First, follow the installation instructions for: | ||
to install GNU Octave on your system. | * [[Octave for macOS|macOS]] | ||
typing <code>octave</code> in a terminal | * [[Octave for GNU/Linux|GNU/Linux]] and [[Octave for other Unix systems|other Unix systems]] | ||
* [[Octave_for_Microsoft_Windows|Microsoft Windows]] | |||
[https://www.gnu.org/software/octave/doc/interpreter/Running-Octave.html | or consult the [https://www.gnu.org/software/octave/doc/interpreter/Installation.html GNU Octave manual] to install GNU Octave on your system. | ||
Then, start the GNU Octave by clicking the icon in the programs menu or launch the interactive prompt by typing <code>octave</code> in a terminal. | |||
See the manual page on [https://www.gnu.org/software/octave/doc/interpreter/Running-Octave.html running Octave]. | |||
[[File:GNU Octave screenshot.png|thumb|center|500px|The GNU Octave graphical user interface (GUI).]] | |||
= Variable Assignment = | = Variable Assignment = | ||
Line 112: | Line 114: | ||
= Control flow | = Control flow with loops = | ||
Octave supports <code>for</code> and <code>while</code> loops, as well as other control flow | Octave supports <code>for</code> and <code>while</code> loops, as well as other control flow | ||
Line 126: | Line 128: | ||
k = 1; | k = 1; | ||
step = 2; | step = 2; | ||
while (k <= | while (k <= 100) | ||
y( | y(k) = k^2; | ||
k = k + step; | k = k + step; | ||
endwhile</syntaxhighlight> | endwhile</syntaxhighlight> | ||
= Vectorization = | = Vectorization = | ||
Line 239: | Line 239: | ||
= Octave | = Octave packages = | ||
Community-developed packages can be added from the | Community-developed packages can be added from the | ||
[ | [https://gnu-octave.github.io/packages/ Octave Packages] website to extend | ||
the functionality of Octave’s core library. (Matlab users: | the functionality of Octave’s core library. (Matlab users: Packages | ||
act similarly to Matlab’s toolboxes.) The [https://www.gnu.org/software/octave/doc/interpreter/XREFpkg.html pkg] command is used | act similarly to Matlab’s toolboxes.) The [https://www.gnu.org/software/octave/doc/interpreter/XREFpkg.html pkg] command is used | ||
to manage these packages. For example, to use the image processing library | to manage these packages. For example, to use the image processing library visit its [https://gnu-octave.github.io/packages/image/ page on Octave Packages,] copy the install command and run it in octave | ||
<syntaxhighlight lang="octave">pkg install - | <syntaxhighlight lang="octave">pkg install "https://downloads.sourceforge.net/project/octave/Octave%20Forge%20Packages/Individual%20Package%20Releases/image-2.14.0.tar.gz" # install package | ||
pkg load image # load new functions into workspace | pkg load image # load new functions into workspace | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[https://www.gnu.org/software/octave/doc/interpreter/Packages.html Read more about packages]. | [https://www.gnu.org/software/octave/doc/interpreter/Packages.html Read more about packages]. | ||
= Octave User Codes = | |||
There are also User Codes available for GNU Octave which are not part of the core program or any of the packages. | |||
[[:Category:User Codes|See Category User Codes]]. | |||
[[Category:Tutorials]] | [[Category:Tutorials]] |