Cody

Problem 44062. Polar Form Complex Number Entry

Solution 1364359

Submitted on 1 Dec 2017 by David Verrelli
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
compdist = @(a,b) abs(a-b); mag = 1; arg_deg=0; c_correct = 1; assert(compdist(cp2r(mag,arg_deg),c_correct)<1e-12)

ans = 1

2   Pass
compdist = @(a,b) abs(a-b); mag = 1; arg_deg=90; c_correct = i; assert(compdist(cp2r(mag,arg_deg),c_correct)<1e-12)

ans = 0.0000 + 1.0000i

3   Pass
compdist = @(a,b) abs(a-b); mag = 5; arg_deg=-30; c_correct = 4.33012701892219e+00 - 2.50000000000000e+00i; assert(compdist(cp2r(mag,arg_deg),c_correct)<1e-12)

ans = 4.3301 - 2.5000i

4   Pass
compdist = @(a,b) abs(a-b); mag = -2; arg_deg=-20; assert(isnan(cp2r(mag,arg_deg)))

5   Pass
compdist = @(a,b) abs(a-b); mag = 0.1; arg_deg=-8000; c_correct = 17.36481776669513e-03 - 98.48077530122045e-03i; assert(compdist(cp2r(mag,arg_deg),c_correct)<1e-12)

ans = 0.0174 - 0.0985i

Suggested Problems

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!