# EGR 272 – Complex Numbers and AC Circuits using MATLAB

## Presentation on theme: "EGR 272 – Complex Numbers and AC Circuits using MATLAB"— Presentation transcript:

EGR 272 – Complex Numbers and AC Circuits using MATLAB
Complex Numbers in MATLAB We will begin this section by looking at several useful functions in MATLAB related to complex numbers. Useful functions in MATLAB related to complex numbers MATLAB function Description Example (MATLAB outputs in red) real(x) Real part of complex number A = 3 + 4i; X = real(A) X = 3 imag(x) Imaginary part of complex number X = imag(A) X = 4 abs(x) Magnitude of a complex number X = abs(3+4i) X = 5 angle(x) Angle of a complex number in radians Alpha = angle(3+4i)*180/pi alpha = conj(x) Complex conjugate of complex number A = 3+4i A = i X = conj(A) X = i

EGR 272 – Complex Numbers and AC Circuits using MATLAB
Useful functions in MATLAB related to complex numbers MATLAB function Description Example (MATLAB outputs in red) [theta, r] = cart2pol(x, y) Converts from rectangular to polar form where theta is in radians [Radians,Mag]=cart2pol(3,4) Radians = Mag = 5 Degrees=Radians*180/pi Degrees = Note: so 3 + 4i = 553.13 [x, y] = pol2cart(theta, r) Converts from polar to rectangular form where theta is in radians [a,b]=pol2cart(30*pi/180,10) a = b = Note: so 1030 = i complex(a,b) Form complex data from real and imaginary parts X = complex(3,4) X = i A = [3;-3;-3;3]; B = [4;4;-4;-4]; C = complex(A,B) C = i i i i

EGR 272 – Complex Numbers and AC Circuits using MATLAB
Useful operations in MATLAB related to complex numbers MATLAB operations Description Example (MATLAB outputs in red) Exponentiation(^) Raise a complex number to a power X = (1+2i)^2 X = i Arithmetic operations Addition (+) Subtraction (-) Multiplication (*) Division (/) Converts from polar to rectangular form where theta is in radians A=3+4i; B=2+6i; A+B ans = i A-B ans = i A*B ans = i A/B ans = i Exponential polar form X = 10*exp(30i*pi/180) X = i [Real,Imag]=pol2cart(30*pi/180,10) Real = Imag = Note: So 10ej30 = 1030

EGR 272 – Complex Numbers and AC Circuits using MATLAB
Printing Complex Numbers in MATLAB Some options for printing complex numbers in MATLAB include: Do not suppress printing and accept the default format (rectangular form): Display using fprintf (not perfect, but may be sufficient in some cases)

EGR 272 – Complex Numbers and AC Circuits using MATLAB
Printing Complex Numbers in MATLAB Some options for printing complex numbers in MATLAB include: Convert complex number to a string using num2str( ) and print using %s:

EGR 272 – Complex Numbers and AC Circuits using MATLAB
6 Application of Complex Numbers: AC Circuit Analysis (Phasor Analysis) AC Circuit Analysis Procedure: 1) Draw the phasor circuit (showing voltage and current sources as phasors and using complex impedances for the components). 2) Analyze the circuit in the same way that you might analyze a DC circuit. 3) Convert the final phasor result back to the time domain. Example: Use the total current using phasor analysis by hand. Solution: See next slide

EGR 272 – Complex Numbers and AC Circuits using MATLAB
Solution: phasor circuit: 500 V 10 30 -j25 -j50 j20 I

EGR 272 – Complex Numbers and AC Circuits using MATLAB
Example: Use MATLAB to solve for the total phasor current.

Download ppt "EGR 272 – Complex Numbers and AC Circuits using MATLAB"

Similar presentations