% Lesson 1: Introduction to the MATLAB Environmnet
% Part 1: The Command Window, Variables, and Operations
% Author: Your name here
% Last Updated: Wednesday 1/9/2019
%
% DECLARE MATLAB VARIABLE
% In our first example class, let's study the syntax (i.e. format or structure) we use to declare variables in MATLAB. The general syntax to declare a variable looks as follows:

%This is a comment (not executable code)
m = 2^8

% In this case, we have:
%     - m is variable name
%     - the equals sign is called the assignment operator
%     - to the right of the equals sign is a (computable) expression
%
% SUPPRESS OUTPUT IN COMMAND WINDOW
% By default, MATLAB prints the output of any command executed in the Command Window. To stop MATLAB from doing this, I can us the semicolon.

%The following code would produce output in the Command Window
b = 2^5

%In contrast, the code below does not produce output
%We use the semicolon to suppress output
c = 2^(-5);

% BASIC ARITHMETIC OPERATORS IN MATLAB
% There are 8 basic arithmetic operations in MATLAB:
%     + : uniary plus (one input) expects an expression to the right
%     + : binary plus (two inputs) expects expressions on left and right side of plus sign
%     - : uniary minus (one input) expect input expression to the right side
%         Note: this is also called negation
%     - : binary minus (two inputs) expects two input expresions on the left and right side of minus sign
%     * : binary multiplication (two inputs) on left and right side of mult sign
%     / : binary right division (two inputs) on left and right side of right division sign
%     \ : binary left division (two inputs) on left and right side of left division sign
%         Note: the left division is really a matrix operation used to solve linear-systems problems
%     ^ : binary exponentiation (two inputs) on the left and right hand side of the carrot
% OPERATOR PRECEDENCE IN MATLAB
% When typing computational expressions that rely only on our basic arithematic operators (see above), MATLAB uses operator precendence to figure out what operations to execute first. In our previous lives, we thought of this as PEMDAS (order of operations). Let's take a look at some useful examples.

%Right division first then addition
2 + 6/3 + 1

%Addition in numerator and denominator first, then right division
(2 + 6)/(3 + 1)

%Add in numerator, then division and finally addition
(2 + 6)/3 + 1

%Add in denominator, then division and finally addition
2 + 6/(3 + 1)

% OPERATOR PRECEDENCE ARTICLE IN DOCUMENTATION
% Any time we need to remember MATLAB's internal operator precedence order, we can use the documentation center to figure this out. To do so, use the search query "precendence" and then choose the article titled "operator precedence."