# Dragon Notes

UNDER CONSTRUCTION
Latest content:
 Apr 05 Deep Learning Mar 19 Anomaly Detection - ML Mar 13 +Data Tables Mar 08 Clustering - Machine Learning Feb 28 Support Vector Machines - ML Feb 20 Regression - Data Science

# MATLAB:Linear Algebra

Matrix basics

A = [1, 2, 3; 4, 5, 6; 7, 8, 9]
# , separates elements, ; separates rows
v = [1;2;3]
[m,n] = size(A)

dim_A = size(A)
A_23 = A(2,3)
I = eye(3)
A_trans = A'
A_inv = inv(A)
% defines a 3x1 vector
% gets dimensions of matrix A, storing them in
% m = rows, n = columns
% can also store in a variable
% stores element in row 2, column 3 into A_23
% defines a 3x3 identity matrix
% takes transpose of A
% takes inverse of A

>> x = zeros(2, 4)
x =
0   0   0   0
0   0   0   0

>> x = A(2, 1)
x =
1.60

>> x = B(end, 2)
x =
5.30

>> x = B(2,end-2)
x =
6.11

>> x = B(:,2)
x =
4.72
9.07
5.30

% generates a 2x4 matrix of zeros

% extracts value of element in row 2, column 1

% extracts value of element in last row and column 2

% extracts value of element in row 2 and col. (last-2)

% creates col. vector specifying all elements in col. 2

>> x = B([1 3],:)
x =
3.00   4.72   0.00
2.54   5.30   4.45

>> A(1,1) = 5.00
A
A =
5.00   1.52
1.60   3.63

>> [Max, iMax] = max(v)
Max =
6.67
iMax =
2

>> max(max(B))
ans =
9.07

>> A(:)
A =
0.86
1.60
1.52
3.63

% creates matrix with all elements in rows 1
% and 3 of mtx. A

% assigns value 5.00 to element in row 1 col. 1
% of mtx. A

% finds max value of input vector, and its index;
% stores value in Max, index in iMax

% returns max value of entire matrix

% put all elements of mtx. A in a single column,
% sorted top-down left-right

>> B = [B, [1; 2; 3]]
B =
3.00   4.72   0.00   1
6.11   9.07   2.87   2
2.54   5.30   4.45   3

% appends a column to the right of mtx. B