Intro To Matlab
Intro To Matlab
ppt
Intro to Matlab
22
3.5, , 4,
7
• In science the term scalar is used as opposed to a
vector, i.e. a magnitude having no direction.
• In MATLAB, scalar is used as opposed to arrays, i.e. a
single number.
• Since we have not covered arrays (tables of numbers)
yet, we will be dealing with scalars in MATLAB.
3-3 Fetching and Setting Scalar
Variables
• Think of computer
variables as named
containers.
• We can perform 2
types of operations
on variables:
Chapter 5
Vector Operations
• Vector Creation
• Accessing Vector Elements
• Row Vectors and Column Vectors, and the
Transpose Operator
• Vector Built-in Functions, Operators, and
Expressions
Vectors and Matrices
• Can be to command line or from *.m file
scalar: x=3
vector: x = [1 0 0]
2D matrix: x = [1 0 0; 0 1 0; 0 0 1]
arbitrarily higher dimensions (don’t use much)
x = 1:10
y = 1:10
z = x’ * y
mesh(x,y,z)
3 4 5 x 32
21 5 2 * y = 20
1 -2 10 z 120
A = [3 4 5; 21 5 2; 1 -2 10]
u = [ x y z]’
b = [ 32 20 120]’
In other words, A u = b (this is linear algebra)
The solution uses matrix inverse
• If you multiply both sides by 1/A you get
u = 1/A * b