Using Octave: Difference between revisions

Jump to navigation Jump to search
485 bytes added ,  17 January 2022
no edit summary
(All output codes are of lang="text")
No edit summary
(5 intermediate revisions by 2 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 156: Line 156:
[https://www.gnu.org/software/octave/doc/interpreter/Two_002dDimensional-Plots.html about plotting].
[https://www.gnu.org/software/octave/doc/interpreter/Two_002dDimensional-Plots.html about plotting].


<syntaxhighlight lang="octave">plot (i/10, w);
<syntaxhighlight lang="octave">plot (i / 10, w);
title ('w = sin(i/10)');
title ('w = sin (i / 10)');
xlabel ('i ÷ 10');
xlabel ('i / 10');
ylabel ('w');</syntaxhighlight>
ylabel ('w');</syntaxhighlight>


<img src="octave_basics-1.png" alt="octave_basics-1.png">
[[File:Using octave-1.png|thumb|center]]
 
 


= Strings =
= Strings =
Line 255: Line 253:


[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]]

Navigation menu