Answered step by step
Verified Expert Solution
Question
1 Approved Answer
- Part 2: Programming Assignment Answer all the questions in this section. 10 marks total. Python has integrated support for complex numbers. See the example
- Part 2: Programming Assignment Answer all the questions in this section. 10 marks total. Python has integrated support for complex numbers. See the example below. (For all of these questions, you may complete them either in Python, in this notebook, or in MATLAB. Here are some details about complex numbers in MATLAB. If you complete the programming assignment in MATLAB, submit all code.) [ ] \# don't modify this cell import numpy as np import matplotlib.pyplot as plt [ \# \# feel free to make modifications to this cell. It won't be graded. print (1+2j) print(np.exp(1j * np.pi/3)) print(np.abs (1p.sqrt(2)+1j1p.sqrt(2))) (1+2j) (0.5000000000000001+0.8660254037844386j) 0.9999999999999999 ( 2 marks) Write a function: toExponential (a,b). The parameters a and b are the real and imaginary parts of a complex number, i.e., a+jb. The function returns a tuple (c,d) which gives the parameters of the same complex number in exponential form: cejd, where c is the magnitude and d is the angle. Write this function from scratch. Do not use any library functions other than trigonometric functions, np.power, np.abs, and np.sqrt. Also give some examples of the use of the function. [ ] \# write toexponential here [ ] \# give examples here (2 marks) Write a function: toCartesian (c,d), which does the opposite of toExponential: given cejd, it returns a tuple (a, b) representing the same complex number in cartesian form: a+jb. Write this function from scratch. Do not use any library functions other than trigonometric functions, np.power, np.abs, and np.sqrt. Also give some examples of the use of the function. [ ] \# write tocartesian here [ ] \# give examples here (4 marks) Write a function: energy (x), which calculates the energy in the complex-valued signal x. Here x is a vector with complex-valued entries, but x can be of any length (you can assume that the length is greater than or equal to 1). Do not use any library functions other than trigonometric functions, np.power, np.abs, and np.sqrt. Also give some examples of the use of the function. [ ] \# write energy here [ ] \# give examples here (2 marks) Write a function: avgPower(x), which calculates the average power in the complex-valued signal x. Make the same assumptions about x as for the energy function. Assume that the time over which the power is measured is equal to the length of the vector. For example, if the length of the vector is 10 , then the energy is expended over 10 time units. Do not use any library functions other than trigonometric functions, np.power, np.abs, and np.sqrt. Also give some examples of the use of the function. [ ] \# write avgPower here [ ] \# give examples here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started