ME 2115 1/27/17
Types/classes (Section 1.3.1)
Real #s
Single
Double
Can store larger
Integers
int 8
int 32
int 64
Characters or strings
Char. enclosed in single quotes
EX: A = "my name"
Char. means characters
A . My name
Whos
Shows type of variable
Format 1.4.1
click to edit
Short
Long
Loose
Compact
- To specify how expressions will be displayed in the command window.*
Operators [1.4.2]
(+ , - , * , / , \, ^)
E --> exponential notation
e^2 means 10^2
Operators precedence [1.4.2.1]
PEMDAS
MATLab will run In this order, ( ), ^, * / \, + -
Practice 1.2
-5^2 = -25, unless you put a parenthesis around the 5
5 8 / (2) * 4 = 80
10 - 6/2 = 7
CH 2.1, 2.2, 2.3
arrays
1D
Row vector, column vector
2D -> matrix
Set of values of the same type, arranged systematically in tabular form.
Row goes from horizontal
Columns are vertical
Vector
row vector --> 1 row, multiple columns
[1 2 - 5 6] . 1X 4 space or comma,, in between elements
Column vector -> multiple rows, 1 column
[ 2 ; 4; 6 ; 7; -8] 5 X 1( ; ==> end of row)
A(row, column)
A(1,3) would denote what is in the first row, third column.
A(end) would denote what is the last element of the list of variables
Colon operator
start : increment: end
EX. 0 : 2 : 11
a = [ 0 2 4 6 8 10]
0 : 3 : 10
a = [ 0 3 6 9]
Linspace
x = linspace ( 0, 10 , 5)
So we are going to start at 0, end at 10, and have 5 points