3 Mathematically if zi a1 b1 i and 22 az b2 i are two nonzer

3. Mathematically, if zi a1 b1 i and 22 az b2 i are two (non-zero) complex numbers, then their quotient is where a2 2i is the complex conjugate of 2, and l22P 22 is the modulus of 22. As usual, i is the complex unit which satisfies i 1. In class, we wrote two functions called cplxadd.m and cplxmul.m, whose purposes were to add and mul- tiply two complex numbers, respectively. Both functions treated a complex number as a struct class variable with two fields: real and imag. Your job here is to write a Matlab function called cplxdiv.m whose purpose is to calculate the quotient of two complex numbers. As with cplxadd.m and cplxmul.m, your function must take 2 struct class inputs called in1 and in2 (each with the same 2 fields: real and imag), and produce a struct class output called out with those same 2 fields. For your convenience, I have included the functions from class with this assignment. To test your function, given the two struct variables real 1 real -2 imag 3 imag 2 the function calls c-cplxdiv(a, b) and d-cplxdiv(b,a) should, respectively, pro- duce the output real 8000 real 0.3077 imag: 1.4000 imag 5385

Solution

function [ cplxquot ] = cplxdiv( cplxa, cplxb )

    Real = cplxa.real*cplxb.real + cplxa.imag*cplxb.imag;
    Img = cplxa.imag*cplxb.real - cplxa.real*cplxb.imag;
  
    divideBy = cplxb.real*cplxb.real + cplxb.imag*cplxb.imag;
  
    cplxquot.real = Real/divideBy;
    cplxquot.imag = Img/divideBy;
end

 3. Mathematically, if zi a1 b1 i and 22 az b2 i are two (non-zero) complex numbers, then their quotient is where a2 2i is the complex conjugate of 2, and l22P

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site