Matlab Lecture1
Matlab Lecture1
Matlab Lecture1
Lecture 1
Matlab Desktop
Arithmetic Operations
Exponentiation A^B
Multiplication A*B
Division A/B
Addition A+B
Subtraction A-B
Arithmetic Operations
Calculate
Average = 1+ 2 + 3 / 3
V1=3*(2^3+2)/2-2
V2=3*(2^3+2)/ (2-2)
Constants & Variables
Ex:
% this is a comment sentences
Matlab Fundamentals: Vectors
• Row Vector: (Matrix with one row)
Ex:
% let's create a simple row vector with 9 elements called
'a'.
a = [1 2 3 4 6 4 3 4 5]
b= [9;9;8;6;9]
Matlab Fundamentals: Matrices
% creating a matrix is as easy as making a
vector, using semicolons (;) to separate the rows
of a matrix.
A = [1 2 0; 2 5 -1; 4 10 -1]
Matrix Arithmetic Operations
•Transpose
Ex:
% we can easily find the transpose of the matrix 'A'.
B = A'
B =
1 2 4
2 5 10
0 -1 -1
Matrix Arithmetic Operations
Note that:
Matrix Arithmetic Operations
•Multiplication:
C = A * B
C = A .* B
Matrix Arithmetic Operations
>> x=[6 6; 8 8] Note that:
x=
6 6
8 8
>> y= [3 3; 2 2]
y=
3 3
2 2
• Right Division:
>> x./y
ans =
2 2
4 4
• Left Division:
>> x.\y
ans =
0.5000 0.5000
0.2500 0.2500
Matrix Arithmetic Operations
• Power:
R= [7 8 4];
S= [2 4 5];
Q=R.^S
Q =
49 4096 1024
Matrix and Vector Operations