Question: Question # 3 : This exercise shows you how to write a MATLAB function that calculates all the complex - valued solutions to the following

Question #3: This exercise shows you how to write a MATLAB function that calculates all the
complex-valued solutions to the following polynomial:
zn = a
where a is a complex number and n is a positive integer. The solutions are called the nth roots of
the complex number a. For the special case of a =1, the solutions are called the nth roots of unity
(see Appendix A in the textbook). Hint: Let a = Aej\phi be the polar form of a. Then there are
exactly n solutions/roots, for k =0,1,..., n 1, given by
z = A 1
n ej \phi +2\pi k
n =
A 1
n ej \phi
n
|{z }
r1
ej 2\pi k
n
|{z }
r2
,
(a) Write a MATLAB function r = myroots(n, a) to find the nth roots of any complex
number by completing the skeleton function provided in myroots.m. The function should
take a and n above and return all of the roots r. Remember to comment your code.1
(b) After the generation of myroots.m, type in the command window,
>> help myroots
Explain: What purpose does this command serve?
(c) Use your function to calculate the 7th roots of j and the 21st roots of j. Check your results!
1It is a good practice to print out intermediate results in your function code for debugging when you are developing
your function. However, please turn off printing of all intermediate results (do you know how?) in the submitted
version of your code to avoid generating extraneously long published report.
8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!