https://www.gnu.org/software/octave/news/release/2018/03/13/octave-4.2.2-released.html

In [1]:

version()

ans = 4.2.2

In [2]:

[2 3 4]' * [4 3 -1]

ans =
8 6 -2
12 9 -3
16 12 -4

In [3]:

rand(3,3)^3

ans =
1.79348 1.04884 2.13434
1.46948 0.65497 1.53891
1.07188 0.50898 1.15476

In [4]:

scatter(sort(rand(1000, 1)), sort(randn(1000, 1)))

In [5]:

i = 0:.1:2*pi; plot(i, sin(i))

In [6]:

pkg load dicom

error: package dicom is not installed
error: called from
load_packages at line 41 column 7
pkg at line 411 column 7

In [7]:

dicomuid()

warning: the 'dicomuid' function belongs to the image package from Octave Forge
which you have installed but not loaded. To load the package, run 'pkg
load image' from the Octave prompt.
Please read <http://www.octave.org/missing.html> to learn how you can
contribute missing functionality.
error: 'dicomuid' undefined near line 1 column 1

In [8]:

pkg load symbolic; syms x; f = sin(x); diff(f,x)

OctSymPy v2.6.0: this is free software without warranty, see source.
Initializing communication with SymPy using a popen2() pipe.
Some output from the Python subprocess (pid 434) might appear next.
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> >>>
OctSymPy: Communication established. SymPy v1.1.1.
ans = (sym) cos(x)

In [9]:

pkg load symbolic; syms x f = 2 * (cos(x) + sin(x)^2) f1 = diff(f, x)

f = (sym)
2
2⋅sin (x) + 2⋅cos(x)
f1 = (sym) 4⋅sin(x)⋅cos(x) - 2⋅sin(x)

In [10]:

xx = -10:0.1:10; plot(xx, f(xx))

error: invalid indices: should be integers or boolean
error: called from
subsref at line 65 column 11

In [11]:

pkg load image

In [12]:

a = ones(100, 100); b = ones(100, 100); b(3, 1) = .5; psnr(a, b)

ans = 46.021

This plot shows the famous 3D sombrero.

A quadratic meshgrid of $x$ and $y$ coordinates is evaluated via $\sqrt{x^2 + y^2} + \epsilon$ and the value $r$ is then the value plotted along the third dimension.

Reference: 3d plots

In [13]:

tx = ty = linspace (-8, 8, 41)'; [xx, yy] = meshgrid (tx, ty); r = sqrt (xx .^ 2 + yy .^ 2) + eps; tz = sin (r) ./ r; mesh (tx, ty, tz); xlabel ("tx"); ylabel ("ty"); zlabel ("tz"); title ("3-D Sombrero plot");

In [ ]:

```
```

This draws the set of points, where the given equation is satisfied. Here, it shows a tilted ellipse.

$x^2 + 3 (y-1)^2 + \frac{x y}{2} = 6$

Reference: ezplot

In [14]:

ezplot (@(x, y) x.^2 + 3 * (y - 1).^2 + .5 * x .* y - 6)

Imagine you want to evaluate a binary function $f(x,\,y) := x + 2 y$.

For evaluating it in vectorized notation, you need a grid for the cartesian product of all $x$ and $y$.

In [15]:

x = 0:3; y = 0:4; [xx, yy] = meshgrid(x, y); xx + 2*yy

ans =
0 1 2 3
2 3 4 5
4 5 6 7
6 7 8 9
8 9 10 11

In [16]:

pkg load odepkg;

warning: function /usr/share/octave/packages/odepkg-0.8.5/ode23.m shadows a core library function
warning: called from
load_packages_and_dependencies at line 48 column 5
load_packages at line 47 column 3
pkg at line 411 column 7
warning: function /usr/share/octave/packages/odepkg-0.8.5/ode45.m shadows a core library function
warning: called from
load_packages_and_dependencies at line 48 column 5
load_packages at line 47 column 3
pkg at line 411 column 7
warning: function /usr/share/octave/packages/odepkg-0.8.5/odeget.m shadows a core library function
warning: called from
load_packages_and_dependencies at line 48 column 5
load_packages at line 47 column 3
pkg at line 411 column 7
warning: function /usr/share/octave/packages/odepkg-0.8.5/odeplot.m shadows a core library function
warning: called from
load_packages_and_dependencies at line 48 column 5
load_packages at line 47 column 3
pkg at line 411 column 7
warning: function /usr/share/octave/packages/odepkg-0.8.5/odeset.m shadows a core library function
warning: called from
load_packages_and_dependencies at line 48 column 5
load_packages at line 47 column 3
pkg at line 411 column 7

In [18]:

dxdt = @(t, x) - 0.24 * x.^2 + t; tsteps = [0:0.1:5]; [t, x] = ode45(dxdt, tsteps, [-1:0.5:3]); plot(t, x)

In [ ]:

```
```