Presentation is loading. Please wait.

Presentation is loading. Please wait.

EGR 115 Introduction to Computing for Engineers Complex Numbers & 3D Plots – Part 1 Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers.

Similar presentations


Presentation on theme: "EGR 115 Introduction to Computing for Engineers Complex Numbers & 3D Plots – Part 1 Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers."— Presentation transcript:

1 EGR 115 Introduction to Computing for Engineers Complex Numbers & 3D Plots – Part 1 Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers

2 Lecture Outline Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers Complex Numbers  Complex data & plotting Slide 2 of 16

3 Complex Numbers & 3D Plots Complex Numbers - Introduction Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers Slide 3 of 16

4 Complex Numbers & 3D Plots Complex Numbers Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers Imag. Axis Real Axis Slide 4 of 16

5 Complex Numbers & 3D Plots Complex Numbers Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers Imag. Axis Real Axis Slide 5 of 16

6 Complex Numbers & 3D Plots Complex Numbers Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers Converting between Polar and Rectangular representations of complex numbers Slide 6 of 16

7 Complex Numbers & 3D Plots Complex Numbers Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers MATLAB support functions for the manipulation of complex numbers Slide 7 of 16

8 Complex Numbers & 3D Plots Complex Numbers Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers Adding complex numbers In rectangular format In polar format Much easier in rectangular format Slide 8 of 16

9 Complex Numbers & 3D Plots Complex Numbers Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers Multiplying complex numbers In rectangular format In polar format Much easier in polar format Slide 9 of 16

10 Complex Numbers & 3D Plots Complex Numbers Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers In-Class Example:  If your lastname begins with A to M (inclusive) o Develop a function which adds two complex numbers in rectangular format  function c3 = add_rect(c1, c2)  Test your algorithm with: » c1 = 3 – 4i and c2 = 2 + 3i  If your lastname begins with N to Z (inclusive) o Develop a function which multiplies two complex numbers in rectangular format  function c3 = mult_rect(c1, c2)  Test your algorithm with: » c1 = 3 – 4i and c2 = 2 + 3i Compare with: c3 = c1 + c2 Compare with: c3 = c1 * c2 Slide 10 of 16

11 Complex Numbers & 3D Plots Complex Numbers – Relational Operators Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers Complex Numbers and Relational Operations  Given: c1 = 2 – 4i and c2 = 3 + 3i  What is the value of c1 == c2 ?  What is the value of c1 ~= c2 ?  What is the value of c1 < c2 ? o How do we make this comparison?  MATLAB only uses the real part!!!  This can lead to unexpected results!!! FALSE TRUE Slide 11 of 16

12 Complex Numbers & 3D Plots Complex Numbers – Plotting Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers Plotting Complex Data  Given the complex function:  Plot y(t) vs 0  t  4  o What did you get? i.e., plot(t, y) Only real part of y was plotted!! Slide 12 of 16

13 Complex Numbers & 3D Plots Complex Numbers – Plotting Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers Plot both real(y(t)) and imag(y(t)) vs 0  t  4  on the same figure plot(t, real(y), 'b', t, imag(y), 'r') legend('real(y)','imag(y)') Slide 13 of 16

14 Complex Numbers & 3D Plots Complex Numbers – Plotting Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers Plot real(y(t)) vs imag(y(t)) % Plot real(y(t)) vs imag(y(t)) plot(y) title('Plot of Real(y) vs Imag(y)') xlabel('Real(y)') ylabel('Imag(y)') % Method #2 - A Polar Plot polar(angle(y), abs(y)); title('A Polar Plot of y') Slide 14 of 16

15 Complex Numbers & 3D Plots Complex Numbers – A Quiz Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers Quiz 8.1  Given  What is the result of: a) x > y b) abs(x) > abs(y) c) real(x) + imag(y) x = 12 + 5i; y = 5 - 13i; TRUE FALSE Slide 15 of 16

16 Next Lecture Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers 3D Plots Slide 16 of 16


Download ppt "EGR 115 Introduction to Computing for Engineers Complex Numbers & 3D Plots – Part 1 Wednesday 05 Nov 2014 EGR 115 Introduction to Computing for Engineers."

Similar presentations


Ads by Google