*
Session IV
Graphs & Matrices
Dr. Afsaneh Mojra
Dept of Mechanical Engineering
Homework
ఱ
ଷ
௫
تﻻدﺎﻌﻣ ﺪﻴﻨﻛ ﻢﻴﺳﺮﺗ ار ﺮﻳز
:
1/39
Homework
Session4: Programming Dr. Afsaneh Mojra ఱ
ଷ
تﻻدﺎﻌﻣ ﺪﻴﻨﻛ ﻢﻴﺳﺮﺗ ار ﺮﻳز
:
2/39
Homework
0 1 2 3 4 5 6 7 8 9 10
1.5 2 2.5 3 3.5 4 4.5 5 5.5 6
x
y
data 1
3/39
Homework
Session4: Programming Dr. Afsaneh Mojra
تﻻدﺎﻌﻣ ﺪﻴﻨﻛ ﻢﻴﺳﺮﺗ ار ﺮﻳز
:
௫
4/39
Homework
0 1 2 3 4 5 6 7 8 9 10
-40 -30 -20 -10 0 10 20
5/39
Plot
Session4: Programming Dr. Afsaneh Mojra
Graph )
يﺪﻌﺑ ود
( 2-D
يا ﻪﻠﻴﻣ رادﻮﻤﻧ (Bar Plot) ﺎﻄﺧ رادﻮﻤﻧ (Error Bar Plot) يا ﻪﻗﺎﺳ رادﻮﻤﻧ (Stem Plot)
يا ﻪﻠﭘ رادﻮﻤﻧ (Step Plot) ﻲﺒﻄﻗ رادﻮﻤﻧ (Polar Plot) يا ﻪﻄﻘﻧ رادﻮﻤﻧ (Scatter Plot)
يا ﻪﻄﻘﻧ رادﻮﻤﻧ (Scatter Plot) ﻲﻄﺧ رادﻮﻤﻧ (Line Plot)
6/39
2-D Plot: Polar Plot
>> Step plot: use Laplacian Transform Polar Plot
7/39
2-D Plot: Polar Plot
Session4: Programming Dr. Afsaneh Mojra 8/39
2-D Plot: Polar Plot
0 1 2 3 4 5 6 7
0.5 1 1.5 2 2.5 3 3.5 4
9/39
2-D Plot: Polar Plot
Session4: Programming Dr. Afsaneh Mojra 10/39
2-D Plot: Polar Plot
1 2
3 4
30
210
60
240
90
270 120
300 150
330
180 0
data1
11/39
2-D Plot: Polar Plot
Session4: Programming Dr. Afsaneh Mojra 12/39
2-D Plot: Polar Plot
13/39
2-D Plot: Polar Plot
Session4: Programming Dr. Afsaneh Mojra
0.2 0.4
0.6 0.8
1
30
210
60
240
90
270 120
300 150
330
180 0
14/39
2-D Plot: Polar Plot
0.2 0.4
0.6 0.8
1
30
210
60
240
90
270 120
300 150
330
180 0
15/39
2-D Plot: Polar Plot
Session4: Programming Dr. Afsaneh Mojra 16/39
2-D Plot: Polar Plot
0.2 0.4
0.6 0.8
1
30
210
60
240
90
270 120
300 150
330
180 0
17/39
2-D Plot: Polar Plot
>>t = 0:.01:2*pi;
>>y=sin(2*t).*cos(2*t)
>>polar(t,y,'--r')
ﺎﻳ
>>t = 0:.01:2*pi;
>>polar(t,sin(2*t).*cos(2*t),'--r')
Session4: Programming Dr. Afsaneh Mojra 18/39
2-D Plot: Polar Plot
0.1 0.2
0.3 0.4
0.5
30
210
60
240
90
270 120
300 150
330
180 0
19/39
2-D Plot: Polar Plot
رﻮﺘﺳدﺪﻨﻧﺎﻣ polar
تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا
ﺖﺳا هﺪﺷ ﻢﻴﺳﺮﺗ رادﺮﺑ ﻚﻳ ﻪﻄﻘﻧ ﺮﻫ ﻪﺑ ﻲﺒﻄﻗ .
رﻮﺘﺳد فﻼﺧ ﺮﺑ Polar
ﺪﻨﻛ ﻲﻣ رﺎﻛ ﻦﻳﺰﺗرﺎﻛ تﺎﺼﺘﺨﻣ ﺎﺑ
ﻲﻟو ترﻮﺼﺑ
ﻚﻴﺗﺎﻤﺷ ﺪﻨﻛ ﻲﻣ ﻢﻴﺳﺮﺗ هﺮﻳاد ﻚﻳ رد
.
Session4: Programming Dr. Afsaneh Mojra
compass
20/39
2-D Plot: Polar Plot
1 . ﻪﻳواز رﻮﺤﻣ ﻒﻳﺮﻌﺗ (θ)
21/39
2-D Plot: Polar Plot
. 2 ﻲﻋﺎﻌﺷ رﻮﺤﻣ ﻒﻳﺮﻌﺗ (r)
Session4: Programming Dr. Afsaneh Mojra 22/39
2-D Plot: Polar Plot
. 3 ﻦﻳﺰﺗرﺎﻛ ﻪﺑ ﻲﺒﻄﻗ تﺎﺼﺘﺨﻣ ﻞﻳﺪﺒﺗ
pol2cart
23/39
2-D Plot: Polar Plot
. 4 رﻮﺘﺳد ياﺮﺟا compass
Session4: Programming Dr. Afsaneh Mojra 24/39
2-D Plot: Polar Plot
2 4
6 8
30
210
60
240
90
270 120
300 150
330
180 0
25/39
Cartesian & polar
ﻞﻳﺪﺒﺗ شور تﺎﺼﺘﺨﻣ
ﻲﺒﻄﻗ ﻦﻳﺰﺗرﺎﻛ ﻪﺑ
) يﺪﻌﺑ ﻪﺳ :(
Session4: Programming Dr. Afsaneh Mojra
Polar (θ, r, z)
Cartesian (x,y,z)
[x, y, z] = pol2cart(θ, r, z)
26/39
Cartesian & polar
ﻞﻳﺪﺒﺗ شور ﻦﻳﺰﺗرﺎﻛ ﻪﺑ ﻲﺒﻄﻗ تﺎﺼﺘﺨﻣ
) ود يﺪﻌﺑ :(
Polar (θ, r)
Cartesian (x,y)
[x, y] = pol2cart(θ, r)
27/39
Cartesian & polar
ﻪﺑ ﻦﻳﺰﺗرﺎﻛ تﺎﺼﺘﺨﻣ ﻞﻳﺪﺒﺗ شور ﻲﺒﻄﻗ
) ﻪﺳ يﺪﻌﺑ
:(
Session4: Programming Dr. Afsaneh Mojra
Cartesian (x,y,z)
Polar (θ, r, z)
[θ, r, z] = cart2pol(x, y, z)
28/39
Cartesian & polar
29/39
Cartesian & polar
ﻪﺑ ﻦﻳﺰﺗرﺎﻛ تﺎﺼﺘﺨﻣ ﻞﻳﺪﺒﺗ شور ﻲﺒﻄﻗ
) ود يﺪﻌﺑ :(
Session4: Programming Dr. Afsaneh Mojra
Cartesian (x,y)
Polar (θ, r)
[θ, r] = cart2pol(x, y)
30/39
Cartesian & polar
31/39
Cartesian & polar
atan2 & atan: Arctan Atan2(y,x)=Arctan(y/x)
Atan(y,x)=Arctan(y/x)
Session4: Programming Dr. Afsaneh Mojra
[-π,π] ﻲﺗﺎﺜﻠﺜﻣ هﺮﻳاد ﻞﻛ
[-π/2,π/2] ﻲﺗﺎﺜﻠﺜﻣ هﺮﻳاد ﻒﺼﻧ
32/39
2-D Plot: Scatter Plot
ﺎﻫ هداد ﺮﻳدﺎﻘﻣ ﻢﻴﺳﺮﺗ ترﻮﺼﺑ
ﻪﺘﺴﺴﮔ )
يا ﻪﻄﻘﻧ (
>>scatter(X,Y)
33/39
2-D Plot: Scatter Plot
Session4: Programming Dr. Afsaneh Mojra
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
0 0.5 1 1.5 2 2.5 3 3.5 4
34/39
M-file: create
35/39
M-file: create
Session4: Programming Dr. Afsaneh Mojra 36/39
M-file
37/39
M-file: Save
Session4: Programming Dr. Afsaneh Mojra 38/39
M-file: Save
39/39