session iv graphs & matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-d plot: polar plot...

40
* Session IV Graphs & Matrices Dr. Afsaneh Mojra Dept of Mechanical Engineering

Upload: others

Post on 15-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

*Session IV

Graphs & Matrices

Dr. Afsaneh Mojra

Dept of Mechanical Engineering

Page 2: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

Homework

Session4: Programming Dr. Afsaneh Mojra

:زير را ترسيم كنيد معادالت

1/39

Page 3: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

Homework

Session4: Programming Dr. Afsaneh Mojra

:زير را ترسيم كنيد معادالت

2/39

Page 4: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

Homework

Session4: Programming Dr. Afsaneh Mojra

0 1 2 3 4 5 6 7 8 9 101.5

2

2.5

3

3.5

4

4.5

5

5.5

6

x

y

data 1

3/39

Page 5: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

Homework

Session4: Programming Dr. Afsaneh Mojra

:زير را ترسيم كنيد معادالت

4/39

Page 6: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

Homework

Session4: Programming Dr. Afsaneh Mojra

0 1 2 3 4 5 6 7 8 9 10-40

-30

-20

-10

0

10

20

5/39

Page 7: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

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

Page 8: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

>> Step plot: use Laplacian Transform

Session4: Programming Dr. Afsaneh Mojra

Polar Plot

7/39

Page 9: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

Session4: Programming Dr. Afsaneh Mojra8/39

Page 10: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

Session4: Programming Dr. Afsaneh Mojra

0 1 2 3 4 5 6 70.5

1

1.5

2

2.5

3

3.5

4

9/39

Page 11: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

Session4: Programming Dr. Afsaneh Mojra10/39

Page 12: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

Session4: Programming Dr. Afsaneh Mojra

1

2

3

4

30

210

60

240

90

270

120

300

150

330

180 0

data1

11/39

Page 13: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

Session4: Programming Dr. Afsaneh Mojra12/39

Page 14: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

Session4: Programming Dr. Afsaneh Mojra13/39

Page 15: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

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

Page 16: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

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

15/39

Page 17: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

Session4: Programming Dr. Afsaneh Mojra16/39

Page 18: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

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

17/39

Page 19: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

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 Mojra18/39

Page 20: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

Session4: Programming Dr. Afsaneh Mojra

0.1

0.2

0.3

0.4

0.5

30

210

60

240

90

270

120

300

150

330

180 0

19/39

Page 21: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

است با اين تفاوت كه از مبدأ مختصات polar ماننددستور.قطبي به هر نقطه يك بردار ترسيم شده است

با مختصات كارتزين كار مي كند Polarبر خالف دستور .در يك دايره ترسيم مي كند شماتيك بصورتولي

Session4: Programming Dr. Afsaneh Mojra

compass

20/39

Page 22: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

(θ)تعريف محور زاويه . 1

Session4: Programming Dr. Afsaneh Mojra21/39

Page 23: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

(r)تعريف محور شعاعي . 2

Session4: Programming Dr. Afsaneh Mojra22/39

Page 24: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

تبديل مختصات قطبي به كارتزين. 3

Session4: Programming Dr. Afsaneh Mojra

pol2cart

23/39

Page 25: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

compassاجراي دستور . 4

Session4: Programming Dr. Afsaneh Mojra24/39

Page 26: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Polar Plot

Session4: Programming Dr. Afsaneh Mojra

2

4

6

8

30

210

60

240

90

270

120

300

150

330

180 0

25/39

Page 27: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

Cartesian & polar): سه بعدي(به كارتزين قطبي مختصات روش تبديل

Session4: Programming Dr. Afsaneh Mojra

Polar (θ, r, z)

Cartesian (x,y,z)

[x, y, z] = pol2cart(θ, r, z)

26/39

Page 28: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

Cartesian & polar): بعديدو (مختصات قطبي به كارتزين روش تبديل

Session4: Programming Dr. Afsaneh Mojra

Polar (θ, r)

Cartesian (x,y)

[x, y] = pol2cart(θ, r)

27/39

Page 29: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

Cartesian & polar):بعديسه (قطبي روش تبديل مختصات كارتزين به

Session4: Programming Dr. Afsaneh Mojra

Cartesian (x,y,z)

Polar (θ, r, z)

[θ, r, z] = cart2pol(x, y, z)

28/39

Page 30: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

Cartesian & polar

Session4: Programming Dr. Afsaneh Mojra29/39

Page 31: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

Cartesian & polar):بعديدو (قطبي روش تبديل مختصات كارتزين به

Session4: Programming Dr. Afsaneh Mojra

Cartesian (x,y)

Polar (θ, r)

[θ, r] = cart2pol(x, y)

30/39

Page 32: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

Cartesian & polar

Session4: Programming Dr. Afsaneh Mojra31/39

Page 33: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

Cartesian & polaratan2 & atan: Arctan

Atan2(y,x)=Arctan(y/x)

Atan(y,x)=Arctan(y/x)

Session4: Programming Dr. Afsaneh Mojra

[-π,π] مثلثاتيكل دايره

[-π/2,π/2] مثلثاتينصف دايره 32/39

Page 34: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

2-D Plot: Scatter Plot

)نقطه اي(گسسته بصورتترسيم مقادير داده ها

Session4: Programming Dr. Afsaneh Mojra

>>scatter(X,Y)

33/39

Page 35: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

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 20

0.5

1

1.5

2

2.5

3

3.5

4

34/39

Page 36: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

M-file: create

Session4: Programming Dr. Afsaneh Mojra35/39

Page 37: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

M-file: create

Session4: Programming Dr. Afsaneh Mojra36/39

Page 38: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

M-file

Session4: Programming Dr. Afsaneh Mojra37/39

Page 39: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

M-file: Save

Session4: Programming Dr. Afsaneh Mojra38/39

Page 40: Session IV Graphs & Matriceswp.kntu.ac.ir/mojra/graph3.pdf · 2-D Plot: Polar Plot تﺎﺼﺘﺨﻣ أﺪﺒﻣ زا ﻪﻛ توﺎﻔﺗ ﻦﻳا ﺎﺑ ﺖﺳا polar رﻮﺘﺳدﺪﻨﻧﺎﻣ.ﺖﺳا

M-file: Save

Session4: Programming Dr. Afsaneh Mojra39/39