%% From Lesson 2.1 Introduction to Matrices and Operators
xvalues = [1, 2, 10]
X = [0 1 -1; 2.5 pi 100]
sqrt(2)
sin(30)
sind(30)
size(X)
x = 5
size(x)
Voltages = [1 2 3; 4 5 6; 7 8 9]
row1_Voltages = [1 2 3]
x = [1 4 7]
y = [1; 4; 7]
size(x)
size(y)

%% From Lesson 2.2 The Colon Operator
x = 1:3:7;
1:3:8
1:3:9
1:3:9.9
1:3:10
ints = 1:100
size(ints)
1+2
plus(1, 2)
colon(1, 7)
1:7
1+2
10*20
1:7
1:3:7
z = 1:2:1000
size(z)
elens = 2:2:500
size(evens)
7:-3:1
down_by_10 = 100:-10:-100
size(down_by_10)
x = 7:3:1
size(x)
x = []
size(x)

%% From Lesson 2.3 Accessing Parts of Matrix
X = [1:4, 5:8, 9:12]
X(2, 3)
center = X(2, 3)
bob = X(3, 3)
X(2, 3) = 97
X(2, 2)
X(2, 2) = 123
X(2, 2)
XYZ %Results in Error: Undefined function or variable 'XYZ'.
XYZ(2, 2) = 123
X(4, 5) %Results in Error: Index exceeds matrix dimensions.
X(4, 5) = 456
X(1, 1) = 99
X = 99
X = [1 2 3; 4 5 6]
X(2, [1 3])
X(2 [1 3]) %Results in Error: Unbalanced or unexpected parenthesis or bracket.
X([2, 1], 2)
X([2, 1, 2], [3, 1, 1, 2])
X([2, 1, 2], [3, 1, 1, 8]) %Results in Error: Index exceeds matrix dimensions.
X(2, [1, 2, 3])
X(2, 1:3)
1:3
X(2:-1:1, 3:-1:1)
X(end, 2)
X(2, end)
end = 5 %Results in Error: Illegal use of reserved keyword "end".
X(1, end)
X(end, 2)
X(end, end)
X([2 end 1 end], 3)
X
X(1, end-1)
X(end - 1, end - 2)
X(1, [end, end-1])
X(end + 1, 1) %Results in Error: Index exceeds matrix dimensions.
X(end + 1, 1) = 17
X(1, 1:2:end)
X(3, end:-1:2)
X(1, end-1:end)
X(1:end, 2)
X(:, 2)
X(1, :)
X(:, :)
X
X(1:end, 1:end)
X(1:end, 1)
X(1:end, 1) = -44
X(1:end, 2:3) = 9
X(1:end, 2:3) = [10 20; 30 40; 50 60]
X(1:end, 2:3) = [10 20]

%% From Lesson 2.4 Combining and Transforming Matrices
A1 = [1 1 1; 1 1 1]
A2 = [2 2 2; 2 2 2]
A3 = [3 3 3; 3 3 3]
[A1 A2 A3]
[A1; A2; A3]
B1 = [1; 1]
B2 = [2 2; 2; 2]
B3 = [3 3 3; 3 3 3]
[B1 B2]
[B1 B2 B3]
[B1 B2 B3 B1]
[B1; B2; B3] %Results in Error using vertcat: Dimensions of matrices being concatenated are not consistent.

H = [1 2 3; 4 5 6]
G = H'
H
x = [1; 3; 5; 7]
x = x'
1:2:5
1:2:5'
(1:2:5)'

%% From Lesson 2.5 Arithmetic Part 1 (new version)
X = [1 5 -2; 3 0 7]
Y = [1:3, 4:6]
Z = X + Y %Results in error using +: Matrix dimensions must agere.
Y = [1:3, 4:6]
Z = X + Y
Z = X - Y

X, Y
Z = X.*Y

Highs_measured = [71.0001, 52.4010, 78.1818; 83.6957, 78.6214, 59.8462]
Calibration_factors = [1.1, 1.5, 0.99; 0.921, 1.001, 1.3]
Highs_true = Highs_measured.*Calibration_factors

A = [1 2 3; 4 5 6; 6 1 1; 0 1 3]
B = [2 -2; 3 8; 7 4]
[size(A), size(B)]
C = A*B
C(3, 2)
A(3, 1)*B(1, 2) + A(3, 2)*B(2, 2) + A(3, 3)*B(3, 2)
B*A %Results in error using * :Inner matrix dimensions must agree

A, B
C = A*B

%% From Lesson 2.6 Arithmetic Part 2 (new version)
2^3
X = [1 2; 3 4]
N = [6 0.5; -1 2]
X.^N
X^3
X*X*X
A = [1 2 3; 4 5 6]
B = [3 5 2; 6 7 2]
A + B
A + 3
3 + A
A - 1
2.*A
2*A
A./2
2./A
2/A %Results in Error using /: Matrix dimensions must agree
A\2 %Results in Error using \: Matrix dimensions must agree
A.^2
2.^A
A
A^2 %Error using ^: Inputs must be a scalar and a square matrix. To compute elementwise POWER, use POWER (.^) instead.






