Sharedoctave.ipynbOpen in CoCalc
Octave 4.2.2
version()
ans = 4.2.2
[2 3 4]' * [4 3 -1]
ans = 8 6 -2 12 9 -3 16 12 -4
rand(3,3)^3
ans = 1.12529 1.35136 0.85930 1.76811 2.18523 1.39527 1.43829 1.75542 1.14817
scatter(sort(rand(1000, 1)), sort(randn(1000, 1)))
i = 0:.1:2*pi;
plot(i, sin(i))
pkg load dicom
dicomuid()
ans = 1.2.826.0.1.3680043.2.1143.1017428757044701398669262255736873157
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 440) might appear next. Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> Waiting...... OctSymPy: Communication established. SymPy v1.1.1. ans = (sym) cos(x)
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)
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
pkg load image
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 xx and yy coordinates is evaluated via x2+y2+ϵ\sqrt{x^2 + y^2} + \epsilon and the value rr is then the value plotted along the third dimension.

Reference: 3d plots

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");

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

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

Reference: ezplot

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+2yf(x,\,y) := x + 2 y.

For evaluating it in vectorized notation, you need a grid for the cartesian product of all xx and yy.

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