clear, clc, close all

%What is nesting??
%uses a combination of for,if,while, by putting one in the other, its order
%of the "shell" changes functionality
%--------------------
%What are conditions??

%==, ~=, >=,>,<,<=
% && means 'and'
% || means 'or'
%purpose is to combine conditional statments

%-----------
%If statements check if a condition is true/false then proceeds if a
%statement true


%if-else statements, it evaluates an if statement, if that isnt true
%proceed to the next if statement and so on until no condition is satisfied
%and thus give a default answer.
%----


%if (condition)
       %statements
%end

x = 10;
y = 13;

if x ~= 13 %Will run if true
    z = x + y; %Will be displayed in the workspace if true.
end

%--------------------
%For loops, do not require conditions
%They take the value of the current itteration given a set of values

%for variable = matrix/scaler
    %statements
%end

x = [1:20];
y = x.^2;

for i = x
    y(i)
end
%---------
%While loops are essentially a combination of if and for, requires a
%conditional statements and functions like an endless for loop until
%condition is false

%You can stuck in an infinite loop. so stop either press the stop button on
%the top of your screen or  press ctr + c if your a windows user.

%initialization
%while (condition)
    %statements
    %have to change/progress the conditional statement
%end

x = 3;
y = 4;

while x <= y
    z = x + y
    x = x + 1;
end


%---------------------Nesting------------------
x = 14;
y = 13;

if x ~= 13 %Will run if true
    if x < 13
        disp("x is less than to y")
    end
    if x > 13
        disp("x is greater than y")
    end
end


x = [1:20];
y = x.^2;

for i = x
    if y(i) >= 144
        y(i) = 0
    elseif y(i) >= 36 && y(i) <= 121 
        y(i) = 2
    else
        y(i) = 1
    end
end
    