Cody

Problem 45281. A "Complex" Converter: Rectangular Form <-> Polar Form

Solution 2149953

Submitted on 4 Mar 2020 by Atsushi Ueno
  • Size: 42
  • This is the leading solution.
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
input1 = 2; %x input2 = 2; %y form = 'r2p'; output1 = 2.8284; output2 = 45; output = [output1;output2]; assert(isequal(round(complexConverter(input1, input2, form),4),output))

2   Pass
input1 = 3; %radius input2 = 60; %degrees form = 'p2r'; output1 = 1.5000; output2 = 2.5981; output = [output1;output2]; assert(isequal(round(complexConverter(input1, input2, form),4),output))

3   Pass
input1 = 3; %x input2 = -4; %y form = 'r2p'; output1 = 5.0000; output2 = 306.8699; output = [output1;output2]; assert(isequal(round(complexConverter(input1, input2, form),4),output))

4   Pass
input1 = 7; %radius input2 = 225; %degrees form = 'p2r'; output1 = -4.9497; output2 = -4.9497; output = [output1;output2]; assert(isequal(round(complexConverter(input1, input2, form),4),output))

Suggested Problems

More from this Author1

Community Treasure Hunt

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

Start Hunting!