%% 0. First of all: Cell mode is cool
% This is a comment

clear all
close all
clc

disp('Hello World!') % This is another comment

%% 1. Working environment

% This is the editor
load handel
sound(y);

doc sound % Most important command of all

save hallelujah.mat

%% Variables
x = 1;      % no output
y = 2       % outputs value of y in console

% Definition of matrices
M1 = [ 1 2 3; 4 5 6];

M2 = eye(3);            % Identity matrix

M3 = zeros(4, 6)        % Matrix full of zeros

u = randn(5,3);         % Random numbers, standardnormal distribution
v = rand(10);           % Random numbers, uniform distribution

% Other ways of defining a vector
i = 1:10;
j = 0:0.2:5;
k = 10:-2:2;

t = u(3,2);              % Find the element of a matrix

% Important matrix manipulations
u5 = transpose(u);
u6 = u';

u2 = randn(5,3);
mult = u'*u2;
element_mult = u.*u2;



%% Flow Control

if (x > 0)
    disp('x is greater than 0')
else
    disp('x is not greater than 0')
end

% Other logical expressions: && == <= >= ~=
if ((x == 1) && (y <= 3))
    disp('x is equal to 1 and y is smaller than 3')
end

% For loops
for i = 1:10
    z(i) = i;
end

j = 1;
while j < 10
    j = j+1;
end

%% Graphics
x = 1:0.1:20;
y = 1:0.1:20;
plot(x, sin(x), y, cos(y));

%%
stem(x, sin(x))

%% Write functions

[test1, test2] = probability(5, 8);

%% Debugging

