Using Octave: Difference between revisions

Jump to navigation Jump to search
712 bytes added ,  13 January 2023
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 installation guide]
First, follow the installation instructions for:
to install GNU Octave on your system. Then, launch the interactive prompt by
* [[Octave for macOS|macOS]]
typing <code>octave</code> in a terminal or by clicking the icon in the programs menu.
* [[Octave for GNU/Linux|GNU/Linux]] and [[Octave for other Unix systems|other Unix systems]]
For further guidance, see the manual page on
* [[Octave_for_Microsoft_Windows|Microsoft Windows]]
[https://www.gnu.org/software/octave/doc/interpreter/Running-Octave.html Running Octave].
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 wih loops =
= 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 <= (100-step))
while (k <= 100)
   y(i) = k^2;
   y(k) = k^2;
   k = k + step;
   k = k + step;
endwhile</syntaxhighlight>
endwhile</syntaxhighlight>


= Vectorization =
= Vectorization =
Line 239: Line 239:




= Octave forge packages =
= Octave packages =


Community-developed packages can be added from the
Community-developed packages can be added from the
[http://octave.sourceforge.net/index.html Octave Forge] website to extend
[https://gnu-octave.github.io/packages/ Octave Packages] website to extend
the functionality of Octave’s core library.  (Matlab users: Forge packages
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
from the Forge, use:


<syntaxhighlight lang="octave">pkg install -forge image # install package
<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]]
Anonymous user

Navigation menu