In a Jupyter Notebook
- This Jupyter Notebook was written by Lilian Besson.
- It uses the unofficial Octave kernel for Jupyter by @Calysto.
In [1]:
% Some variables
N = 100
disp(['Number of values N =', num2str(N)])
h = 1 / N
disp(['Step h = ', num2str(h)])
In [2]:
% Some arrays
t = 0 : h : 2*pi;
x = cos(t);
y = sin(t);
length(t)
length(x)
length(y)
In [3]:
fig = figure();
plot(t, x, 'r*-')
grid on
hold on
plot(t, y, 'b+-')
legend(['\cos(t)', '\sin(t)'])
title('Cosinus and sinus on [0, 2 \pi]')
% whitebg(fig);
In [4]:
fig = figure();
grid on
plot(x, y)
title('\sin(t) as function of \cos(t)')
% whitebg(fig);
In [5]:
a = [[1 0 1]; [0 1 1]; [1 1 0]]
In [6]:
a'
In [7]:
b = 1 + a^5
eig
gives the eigen values:
In [8]:
l_a = eig(a)
l_b = eig(b)
In [9]:
[Ua, Sa, Va] = svd(a)
[Ub, Sb, Vb] = svd(b)
In [10]:
x = linspace(-2, 2, 50);
y = linspace(-2, 2, 50);
[xx,yy] = meshgrid(x, y);
mesh(xx, yy, 4 - (xx.^2 + yy.^2))
In [11]:
x = linspace(-2, 2, 50);
y = linspace(-2, 2, 50);
[xx,yy] = meshgrid(x, y);
meshc(xx, yy, 4 - (xx.^2 + yy.^2))
In [13]:
# From https://octave.sourceforge.io/octave/function/plot3.html
z = [0:0.05:5];
plot3(cos (2*pi*z), sin (2*pi*z), z, ";helix;");
plot3(z, exp (2i*pi*z), ";complex sinusoid;");
In [14]:
clf;
z = [0:0.05:5];
plot3 (cos (2*pi*z), sin (2*pi*z), z);
legend ("helix");
title ("plot3() of a helix");
In [15]:
clf;
colormap ("default");
[X, Y] = meshgrid (linspace (-3, 3, 40));
Z = sqrt (abs (X .* Y)) ./ (1 + X.^2 + Y.^2);
meshc (X, Y, Z);
title ("meshc() combines mesh/contour plots");