SLIDE 3 6/7/2017 3
Ba sic MAT L AB Co ding
- use the interactive commands
– The result stored in “ans”
- Initiate variable and assign a
value
- The equals sign (=) in MATLAB
is the assignment operator
– Value goes from the right to the left
- = is NOT the equal sign
- Use the semicolon to suppress
the output
- Recall the previous commands
by the Up arrow key
- When you enter just a variable
name, MATLAB returns the current value of that variable
reference, so changing one variable does not affect another
Go to: http://www.machinelearninghellix.site/ Download “day one exercise”
Sto ring Da ta in Va ria b le s
- A MATLAB variable starts with a
letter and contain only letters, numbers, and underscores(_)
- Use: clear <variable name> to clear
the values in the variable
- Entering clear only will clean all
variable
- Use clc to clears the Command
Window
- MATLAB constants: pi, i
- We can use a script to define a set of
MATLAB constants (MATLAB class
- n Day 2)
- MATLAB contains a wide variety of
built‐in functions, such as abs (absolute value), trigonometry functions, and eig (calculate eigenvalues)
- MATLAB uses parentheses to pass
inputs to functions, similar to standard mathematical notation.
MAT L AB Built-in F unc tio ns & Co nsta nts