Académique Documents
Professionnel Documents
Culture Documents
to
MATLAB
By Hisham Abuella
TA & RA in ECE @ Istanbul ehir University
Email : hishamabuella@std.sehir.edu.tr
Outline
Where to use MATLAB ?
What is Matlab & Why use it ?
MATLAB Desktop
Exercise 1
Matrices & Vectors
Exercise 2
Useful Sites
MATLAB Desktop
1- Command Window
2- Command History
3- Workspace
4- Current Directory
Exercise 1
Hint
:
^ : power
sqrt: square root
= (2^3)
Solutions to Exercise 1
https://youtu.be/rZuAns0iEt4?t=20s
16
5
3
10
Remember Matrix(row,column)
column vector
row vector
The : operator
VERY important operator in Matlab
Means to
>> 1:10
ans =
1
10
>>A(:,2)
ans =
2
1
1
Whatll happen if you type A(:,:) ?
Creating Vectors
1- Create vector with equally spaced intervals
x=0:0.5:pi
2- Create vector with n equally spaced intervals
x=linspace(0, pi, 7)
, uses i or j to represent
Creating Matrices
zeros(m, n): matrix with all zeros
ones(m, n): matrix with all ones.
eye(m, n): the identity matrix
randn(m, n): normally distributed random
+: addition
-: subtraction
^: exponentiation
*: multiplication
/: division
Manipulating Vectors
Evaluated element by element
.'
.^
.*
./
:
:
:
:
array
array
array
array
Manipulating Matrices
Try These :
-For :
% matrix multiplication
>> B/A
% matrix division
>> B./A
% Subtract B from A
>> A^2
% calculate A square
A=
4
1
5
-1
2
7
&
2
4
0
B=
-1
1
4
8
2
2
3
6
0
Exercise 2
Exercise 2 (Continue)
Solutions
https://youtu.be/pTdkD1UpGjU?t=28s
HW
Useful Sites
http://www.see.ed.ac.uk/teaching/courses/matlab/
http://www.tutorialspoint.com/matlab/matlab_overview.
htm
http://www.mathworks.com/help/matlab/index.html
http://www.mathworks.co.uk/matlabcentral/