%% SL4:
z = 1 + 1j;
s = conj(z);

s = z'

Z   = abs(z)
phi = angle(z)
phi_deg = phi/pi*180
zm = Z*(cos(phi)+1j*sin(phi))

%% SL5:
Z  = [1+1j, sqrt(2)]
Zz = abs(Z);
sqrt(Zz(1)^2 + Zz(2)^2)

% or...
sqrt(Zz*Zz')

norm(Z)
sqrt(dot(Z, Z))
hypot(Z(1), Z(2))

%% SL8:
u = 1:2:99,
v = (25:-5:-5).'

T = [-4:-1:-6; 1:3; pi/2 pi/4 pi/6].'

T = [-4:-1:-6; 1:3; pi./(2:2:6)].'
T = [(-4:-1:-6).' (1:3).' (pi./(2:2:6)).']

%% SL10:
u = linspace(-1.15, 75.4)

v = linspace(100, -100, 201)

v = 100:-10:-100
v = linspace(100, -100, 200/10+1)

%% SL13:
M1 = NaN(2),
M2 = ones(1, 4),
M3 = diag([2 3 -5]),
M4 = diag([1 1 1], 1);

% or...
M4 = [zeros(4,1) [eye(3); zeros(1,3)]],
M4 = diag(ones(3, 1), 1)

%% SL14
A1 = zeros(0, 0, 0) % or ones(...) etc.
A2 = double.empty(0, 0, 0)

%% SL22:
A = [1 pi; exp(1) -1i]

A1 = repmat(A, [1 3]);
A2 = reshape(A.', [1 4]);
A3 = repmat(conj(A), [3 1]);
A4 = triu(tril(repmat(A, [3 3]), 1), -1);

%% SL23:
A = [1:3;0:2:4;0 0 5],
A = repmat(A, [1 2]),

save('matrix.mat', 'A')

B = fliplr(A)
C = flipud(B)

save('matrix.mat', 'B', 'C', '-append')
%% SL29:
x  = 0:pi/20:2*pi;
f1 = sin(x);
f2 = cos(x).^2;
f3 = f1 + f2;

plot(x,f1, x,f2, x,f3)

%% SL30:
clear; clc;
x  = linspace(0, 5*pi, 1e5);
f4 = (-cos(3*x)) ./ (cos(x).*sin(x-pi/5)-pi);
plot(x, f4);

%% SL31:
x  = linspace(0, 2, 1e2+1)';
y  = x';
f  = x*y;
figure; surf(x, y, f);

% or...
x  = linspace(0, 2, 1e2+1);
y  = linspace(0, 2, 1e2+1)';
X1 = repmat(x, [1e2+1 1]);
Y1 = repmat(y, [1 1e2+1]);
f1 = X1.*Y1;
figure; surf(X1, Y1, f1);

%% SL34:
A = rand(2+randi(10), 3+randi(5));
A(:,:,2) = flipud(fliplr(A));

size(A)
numel(A)
length(A)
ndims(A)

%% SL39:
M = 8*rand(3, 4, 2) - 0.5

%% SL40:
% yes
% no
% no
% yes
% yes
% yes

%% SL41:
% corrected code
clear all;
x = linspace(0, 1, 200);
g = x.^3+1; h = x+2;
y = cos(x*pi); z = x.^2;
f = y.*z./(g.*h)
plot(x, f);

