Cody

Problem 44062. Polar Form Complex Number Entry

Solution 1117789

Submitted on 8 Feb 2017 by Peng Liu
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)

[Warning: File: cp2r.m Line: 2 Column: 5 This try-catch syntax will continue to work in R2007b, but may be illegal or may mean something different in future releases of MATLAB. See MATLAB R2007a Release Notes, "Warning Generated by try-catch" for details.]

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)

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)

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)

Suggested Problems

Community Treasure Hunt

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

Start Hunting!