% Basic Operations
% + - * / ^ '

2+3
a=2+3;
a
sqrt(42)
x = [1 2 3] % a row vector
y = [1;2;3] % a column vector

size(x)
x'
size(x')
size (y)


% Matrices
A = [1 2 3;4 5 6]
A(2,3)
A(:,2)
A(1,:)
A'
inv(A) % Matrix is not squared wont work

A=[A;8 3 4] % add a semicolumn ';' at the end of the command if you don't want to see the matrix

inv(A)

% Matrix operations
A + 5
A
A.^2
x.^2
x * x'
x' * x


% Relational Operators

%      <  less than

%      <=  less than or equal

%      >  greater than

%      >=  greater than or equal

%      ==  equal

%      ~=  not equal


% Logical Operators

% &, | and ~ are the"and", "or" and "not" logical operators.


% Vectorization.

A = [1 2 3; 4 5 6]

B = [7;8]

% We want to multiply each row of A with the corresponding row of B
% Q: How can we do this ?

C = [1 2 3];
repmat(C,[1 1])
repmat(C,[1 2])
repmat(C,[2 1])
repmat(C,[3 4])

% Back to our example
repmat(A,[2 3])

B_rep = repmat(B,[1 3])
A .* B_rep


% Moving to more than two dimensions.

B=ones(5) % a 5x5 matrix of ones
B=eye(5) % a 5x5 identity matrix
B=zeros(5,6) % a 5x6 matrix of zeros
B=ones(3,2,4) % more that 2-dim is no problem!

B=repmat(A,[2,3,2]) % also no problem for repmat!


% Some simple plotting

n = 0:11;
x = 1:0.1:5
size(x)

y = sin((pi/6)*n);

plot(n,y)

plot(y)

help plot

% format is is plot(x,y,line-type).

plot(n,y,'-') % the default

plot(n,y,':') % dotted line

plot(n,y,'--')% dashed line

plot(n,y,'r.') % red dots

plot(n,y,'bx') % blue xs

% Add a title
title('MATLAB Graph #1') % adds a title

% Similarly, the following commands label the x- and y-axes:

xlabel('This is the x-axis')
ylabel('This is the y-axis')

hold on
plot(n,y) % add to the same graph
hold off


%Loading data.

help load
data1 = load('biometric_data_simple.txt'); data(:,1:2)
plot(data(:,1),data(:,2),'.')

rawdata = dlmread('biometric_data_simple.txt');
data.C=rawdata(:,1); % Class
data.X=[rawdata(:,2) rawdata(:,3)] %input matrix

help scatter
scatter(data.X(:,1), data.X(:,2),10,data.C)
