Document

advertisement
1
MATLAB
Eng. Osama Talaat
osama063@msn.com
Faculty of Engineering, Zagazig University, Egypt 2013
2
Course Web Page
www.osamatalaat.com/matlab
 You can also navigate to it by:
www.osamatalaat.com >> Teaching >> Matlab.
 You shall find lecture materials and course
resources.
 Bookmark this page and keep visiting it
regularly after each lecture to download its
material.
About MATLAB
3
Calculator
Solving Equations
Matrices
Graphs
Programming
Language
Console programs
GUI
Toolboxes
Communication
Control Systems
Image Processing
Simulation Simulink
4
Lecture (1)
Introduction
Eng. Osama Talaat
5
MATLAB R2013a
 Latest version – Download from the webpage.
6
MATLAB Setup
Open
MATLAB
7
Arithmetic Operators
10 + 2
10 – 2
10 × 2
8
Arithmetic Operators
102
10 ÷ 2
/
\
9
Layout: Command Window
 Clear command window using GUI
 Clear command window using Commands
>> clc
10
Layout: Command History
 Clear command history
11
Layout Controllers
 Undock → Dock
 Maximize → Restore.
 Minimize → Restore.
 Move the tab.
‫‪Variables‬‬
‫قيمة مباشرة‬
‫ناتج عملية‬
‫حسابية‬
‫متغير من آخر‬
‫‪12‬‬
Variables
13
‫متغير من نفسه‬
NB: Names (variables, files, …)
 characters & Numbers, but starts with char.
 No spaces.
 No symbols except underscores (_).
 Case sensitive (also commands).
 Maximum length = 64 (increasing value).
NB: display variable value.
14
Note: Simi-Colon (;)
15
Note: Multiplying by variable
No implicit multiplying sign
16
Layout: Workspace
 Save variables …
17
Layout: Current Directory
 Current Directory address
bar.
 Change Current Directory.
Layout: Workspace
18
 Save variables:
 Ctrl + S
 GUI
 Code
>> save osama.mat
 Clear workspace using
GUI and Code.
>> clear a
>> clear b c
>> clear
 Load saved variables:
 Ctrl + O
 Code
>> load osama.mat
‫‪Special Values: ans‬‬
‫ناتج‬
‫آخر‬
‫عملية‬
‫حسابية‬
‫لم‬
‫يتم‬
‫تخزينها‬
‫‪19‬‬
20
Special Values: PI, INF
𝜋 = 3.14
Infinity
∞
21
Special Values: NaN
‫كمية‬
‫غير‬
‫محددة‬
Trigonometric Functions
>> sin(x)
>> sind(x)
>> cos(x)
>> cosd(x)
>> tan(x)
>> tand(x)
>> sec(x)
>> secd(x)
>> csc(x)
>> cscd(x)
>> cot(x)
>> cotd(x)
Degrees
Radian by default
22
23
Inverse Trigonometric Functions
Radian
Degrees
>> asin(x)
>> asind(x)
>> acos(x)
>> acosd(x)
>> atan(x)
>> atand(x)
>> asec(x)
>> asecd(x)
>> acsc(x)
>> acscd(x)
>> acot(x)
>> acotd(x)
Maths
24
Hyperbolic Functions
>> sinh(x)
>> asinh(x)
>> cosh(x)
>> acosh(x)
>> tanh(x)
>> atanh(x)
>> sech(x)
>> asech(x)
>> csch(x)
>> acsch(x)
>> coth(x)
>> acoth(x)
25
Other Mathematical Functions
>> log10(100)
>> log2(1024)
>> log(3)
>> exp(3)
>> abs(-12)
>> sqrt(16)
>> nthroot(27,3)
Test yourself
26
 If x=1 calculate the following:
𝑓=
5 log 𝑥+2𝑥 3 sin 𝑥+ln 𝑥 𝑥
2
6𝑥
𝑒
+3𝑥 4 +cos 𝑥
>> x=1;
>> f=( 5*log10(x)+2*x^3*sin(x)+log(x)*sqrt(x) ) / (
exp(6*x^2)+3*x^4+cos(x) )
f =
0.0041
‫‪Other Mathematical Functions‬‬
‫إيجاد األعداد‬
‫األولية حتى‬
‫الرقم ‪10‬‬
‫اختبار‬
‫هل‬
‫العدد‬
‫أولي‬
‫أم‬
‫ال‬
‫‪27‬‬
‫‪Other Mathematical Functions‬‬
‫تحليل العدد إلى‬
‫مكوناته األولية‬
‫مضروب العدد‬
‫!‪5‬‬
‫‪28‬‬
29
Complex Numbers
i or j
30
Complex Numbers
Using i or
j as
variables
implicit
multiplying
sign
‫‪Complex Numbers‬‬
‫القيمة‬
‫المطلقة للعدد‬
‫المركب‬
‫زاوية العدد‬
‫المركب‬
‫المرافق‬
‫‪31‬‬
‫‪Complex Numbers‬‬
‫الجزء الحقيقي‬
‫الجزء التخيلي‬
‫اختبار وجود‬
‫جزء تخيلي من‬
‫عدمه‬
‫‪32‬‬
33
Complex Numbers
34
Approximation Functions
Normal
Approximation
35
Approximation Functions
Round
towards
positive
infinity
36
Approximation Functions
Round
towards
negative
infinity
37
Approximation Functions
Round
towards
Zero
38
Approximation Functions
Round
towards
Zero
Help !!
39
 Demos.
MATLAB Tips
40
>> bench
41
GOOD LUCK
To be continued in the next lecture …
Download