INC 151 Electrical Engineering So3ware Prac6ce Lecture #3 - - PowerPoint PPT Presentation

inc 151 electrical engineering so3ware prac6ce
SMART_READER_LITE
LIVE PREVIEW

INC 151 Electrical Engineering So3ware Prac6ce Lecture #3 - - PowerPoint PPT Presentation

INC 151 Electrical Engineering So3ware Prac6ce Lecture #3 Plot func6ons Assoc. Prof. Dr. Benjamas PanomruCanarug benjamas.pan@kmuC.ac.th INC 151 BP 1


slide-1
SLIDE 1

INC ¡151 ¡Electrical ¡Engineering ¡ So3ware ¡Prac6ce ¡

Lecture ¡#3 ¡Plot ¡func6ons ¡ ¡

  • Assoc. ¡Prof. ¡Dr. ¡Benjamas ¡PanomruCanarug ¡

benjamas.pan@kmuC.ac.th ¡

1 ¡ INC ¡151 ¡ BP ¡

slide-2
SLIDE 2

PloIng ¡func6ons ¡

  • x-­‑y ¡plots: ¡plot(x,y) ¡

¡ ¡ ¡ ¡ ¡plot ¡(x1,y1,x2,y2,…,xn,yn) ¡

  • Axis, ¡grid, ¡hold, ¡polar, ¡text, ¡6tle, ¡xlabel, ¡

ylabel ¡

  • Example: ¡plot ¡a ¡func6on ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡

0<t<4 ¡(step ¡= ¡0.5) ¡

INC ¡151 ¡ BP ¡ 2 ¡

slide-3
SLIDE 3

Line ¡types ¡

  • Solid ¡(_) ¡
  • Dash ¡(-­‑) ¡
  • DoCed ¡(:) ¡
  • Dashdot ¡(-­‑.) ¡
  • Point ¡(.) ¡
  • Plus ¡(+) ¡
  • Star ¡(*) ¡
  • Circle ¡(o) ¡
  • X-­‑mark ¡(x) ¡

¡

INC ¡151 ¡ BP ¡ 3 ¡

slide-4
SLIDE 4

colors ¡

  • Red ¡(r) ¡
  • Green ¡(g) ¡
  • Blue ¡(b) ¡
  • White ¡(w) ¡
  • Invisible ¡(i) ¡

INC ¡151 ¡ BP ¡ 4 ¡

slide-5
SLIDE 5

Example ¡

¡Plot ¡voltage ¡and ¡current ¡source ¡shown ¡below: ¡ ¡0<t<20 ¡msec ¡(6me ¡step ¡= ¡1 ¡msec) ¡

INC ¡151 ¡ BP ¡ 5 ¡

slide-6
SLIDE 6

subplots ¡

  • Subplot ¡(i ¡j ¡k) ¡

– i ¡and ¡j ¡specify ¡that ¡the ¡graph ¡window ¡is ¡split ¡into ¡ an ¡i-­‑by-­‑j ¡grid ¡of ¡smaller ¡windows ¡ – k ¡specifies ¡the ¡kth ¡window ¡for ¡the ¡plot ¡

  • Example: ¡let ¡-­‑4<x<4 ¡(step ¡= ¡0.5), ¡plot ¡y ¡= ¡x^2 ¡in ¡

the ¡top ¡half ¡and ¡z ¡= ¡x^3 ¡in ¡the ¡boCom ¡half ¡

INC ¡151 ¡ BP ¡ 6 ¡

slide-7
SLIDE 7

Other ¡plots ¡

  • Stem(x) ¡

INC ¡151 ¡ BP ¡ 7 ¡

slide-8
SLIDE 8

Exercise ¡

  • Write ¡a ¡script ¡file ¡named ¡‘exer1.m’ ¡to ¡plot ¡the ¡

magnitude ¡of ¡the ¡impedance ¡ ¡ ¡ ¡if ¡L ¡= ¡4 ¡mH, ¡C ¡= ¡25µF, and R = 120 Ω for ¡w= ¡ 10, ¡100, ¡1000, ¡10000, ¡and ¡100000 ¡

INC ¡151 ¡ BP ¡ 8 ¡

slide-9
SLIDE 9

Exercise ¡(cont.) ¡

  • Write ¡a ¡script ¡file ¡named ¡‘exer2.m’ ¡to ¡plot ¡

m(t), ¡c(t), ¡and ¡s(t) ¡using ¡the ¡subplot ¡command ¡

INC ¡151 ¡ BP ¡ 9 ¡