1,852
edits
m (→Linear Algebra: Fix pre --> syntaxhighlight) |
(All output codes are of lang="text") |
||
Line 27: | Line 27: | ||
<syntaxhighlight lang="octave">t = 99 + 1 # prints 't = 100'</syntaxhighlight> | <syntaxhighlight lang="octave">t = 99 + 1 # prints 't = 100'</syntaxhighlight> | ||
<syntaxhighlight>t = 100</syntaxhighlight> | <syntaxhighlight lang="text">t = 100</syntaxhighlight> | ||
<syntaxhighlight lang="octave">t = 99 + 1; # nothing is printed | <syntaxhighlight lang="octave">t = 99 + 1; # nothing is printed | ||
disp(t);</syntaxhighlight> | disp(t);</syntaxhighlight> | ||
<syntaxhighlight> 100</syntaxhighlight> | <syntaxhighlight lang="text"> 100</syntaxhighlight> | ||
= Elementary math = | = Elementary math = | ||
Line 41: | Line 41: | ||
<syntaxhighlight lang="octave">x = 3/4 * pi; | <syntaxhighlight lang="octave">x = 3/4 * pi; | ||
y = sin (x)</syntaxhighlight> | y = sin (x)</syntaxhighlight> | ||
<syntaxhighlight>y = 0.70711</syntaxhighlight> | <syntaxhighlight lang="text">y = 0.70711</syntaxhighlight> | ||
Line 53: | Line 53: | ||
[https://www.gnu.org/software/octave/doc/interpreter/Linear-Algebra.html about matrices]. | [https://www.gnu.org/software/octave/doc/interpreter/Linear-Algebra.html about matrices]. | ||
<syntaxhighlight lang="octave">rowVec = [8 6 4]</syntaxhighlight> | <syntaxhighlight lang="octave">rowVec = [8 6 4]</syntaxhighlight> | ||
<syntaxhighlight>rowVec = | <syntaxhighlight lang="text">rowVec = | ||
8 6 4 | 8 6 4 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="octave">columnVec = [8; 6; 4]</syntaxhighlight> | <syntaxhighlight lang="octave">columnVec = [8; 6; 4]</syntaxhighlight> | ||
<syntaxhighlight>columnVec = | <syntaxhighlight lang="text">columnVec = | ||
8 | 8 | ||
6 | 6 | ||
Line 65: | Line 65: | ||
<syntaxhighlight lang="octave">mat = [8 6 4; 2 0 -2]</syntaxhighlight> | <syntaxhighlight lang="octave">mat = [8 6 4; 2 0 -2]</syntaxhighlight> | ||
<syntaxhighlight>mat = | <syntaxhighlight lang="text">mat = | ||
8 6 4 | 8 6 4 | ||
2 0 -2 | 2 0 -2 | ||
Line 71: | Line 71: | ||
<syntaxhighlight lang="octave">size(mat)</syntaxhighlight> | <syntaxhighlight lang="octave">size(mat)</syntaxhighlight> | ||
<syntaxhighlight>ans = | <syntaxhighlight lang="text">ans = | ||
2 3 | 2 3 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="octave">length(rowVec)</syntaxhighlight> | <syntaxhighlight lang="octave">length(rowVec)</syntaxhighlight> | ||
<syntaxhighlight>ans = 3</syntaxhighlight> | <syntaxhighlight lang="text">ans = 3</syntaxhighlight> | ||
Line 87: | Line 87: | ||
<syntaxhighlight lang="octave">columnVec * rowVec</syntaxhighlight> | <syntaxhighlight lang="octave">columnVec * rowVec</syntaxhighlight> | ||
<syntaxhighlight>ans = | <syntaxhighlight lang="text">ans = | ||
64 48 32 | 64 48 32 | ||
48 36 24 | 48 36 24 | ||
Line 94: | Line 94: | ||
<syntaxhighlight lang="octave">rowVec * columnVec</syntaxhighlight> | <syntaxhighlight lang="octave">rowVec * columnVec</syntaxhighlight> | ||
<syntaxhighlight>ans = 116</syntaxhighlight> | <syntaxhighlight lang="text">ans = 116</syntaxhighlight> | ||
<syntaxhighlight lang="octave">columnVec'</syntaxhighlight> | <syntaxhighlight lang="octave">columnVec'</syntaxhighlight> | ||
<syntaxhighlight>ans = | <syntaxhighlight lang="text">ans = | ||
8 6 4 | 8 6 4 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 108: | Line 108: | ||
<syntaxhighlight lang="octave">mat(2,3)</syntaxhighlight> | <syntaxhighlight lang="octave">mat(2,3)</syntaxhighlight> | ||
<syntaxhighlight>ans = -2</syntaxhighlight> | <syntaxhighlight lang="text">ans = -2</syntaxhighlight> | ||
Line 176: | Line 176: | ||
[firstString, secondString] # concatenate both strings | [firstString, secondString] # concatenate both strings | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight>ans = hello world!</syntaxhighlight> | <syntaxhighlight lang="text">ans = hello world!</syntaxhighlight> | ||
<syntaxhighlight lang="octave">fprintf ("%s %.10f \n", "The number is:", 10)</syntaxhighlight> | <syntaxhighlight lang="octave">fprintf ("%s %.10f \n", "The number is:", 10)</syntaxhighlight> | ||
<syntaxhighlight>The number is: 10.0000000000</syntaxhighlight> | <syntaxhighlight lang="text">The number is: 10.0000000000</syntaxhighlight> | ||
Line 207: | Line 207: | ||
endfor</syntaxhighlight> | endfor</syntaxhighlight> | ||
<syntaxhighlight>i=1: | <syntaxhighlight lang="text">i=1: | ||
i=2: | i=2: | ||
i=3: Fizz | i=3: Fizz |