{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":45281,"title":"A \"Complex\" Converter: Rectangular Form \u003c-\u003e Polar Form","description":"*BACKGROUND / MOTIVATION:*\r\n\r\nComplex numbers can be an important tool in an electrical engineer's toolbox because they can help us describe / work with sinusoidal signals.\r\n\r\nSinusoidal signals can be found all over the place in day-to-day life (in music, light, communication systems, power systems, etc.):\r\n\r\n* \"Why Study Sinusoids?\": \u003chttps://www.youtube.com/watch?v=yXjXJ5OlNyQ\u003e\r\n* \"Euler's formula\": \u003chttps://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-eulers-formula\u003e\r\n\r\nWhen working with complex numbers, sometimes it's easier to work with the \"rectangular/Cartesian form\" (z = x + j*y) and sometimes it's easier to work with the \"polar form\" (r ∠ θ).\r\n\r\n_An analogy:_\r\n\r\n* Using the rectangular form is sometimes like using decimals: it can make the numbers easier to add / subtract\r\n* Using the polar form is sometimes like using fractions: it can the numbers easier to multiply / divide\r\n* In the end, the two forms are equivalent, but sometimes they're easier to work with in one form instead of another.\r\n\r\n*PROBLEM DESCRIPTION*\r\n\r\nWrite a function which converts between the rectangular form and the polar form.\r\n\r\nYou can view a comparison of the two forms here:\r\n\u003chttps://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-complex-numbers\u003e\r\n\r\nThe variable \"form\" will be used to determine whether the function converts from rectangular to polar or from polar to rectangular.\r\n\r\nThe function takes the following inputs:\r\n\r\n* \"input1\" - a variable which is either \"x\" (the real component in rectangular form) or \"r\" (the radius in polar form)\r\n* \"input2\" - a variable which is either \"y\" (the complex component in rectangular form) or \"theta\" (the angle, in degrees, in polar form)\r\n* \"form\" - a variable which is set to either \"r2p\" (to convert from rectangular to polar) or \"p2r\" (to convert from polar to rectangular)\r\n\r\nThe function will output the variable \"output\" in the form of a column vector [output1;output2] where:\r\n\r\n* \"output1\" - a component of the output which is either \"x\" (the real component in rectangular form) or \"r\" (the radius in polar form)\r\n* \"output2\" - a component of the output which is either \"y\" (the complex component in rectangular form) or \"theta\" (the positive angle, in degrees, in polar form)\r\n\r\nThe test suite will round the components of your output vector to 4 decimal places.\r\n\r\n*FEEDBACK*\r\n\r\nPlease feel free to leave feedback on this problem in the comments!  :)","description_html":"\u003cp\u003e\u003cb\u003eBACKGROUND / MOTIVATION:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eComplex numbers can be an important tool in an electrical engineer's toolbox because they can help us describe / work with sinusoidal signals.\u003c/p\u003e\u003cp\u003eSinusoidal signals can be found all over the place in day-to-day life (in music, light, communication systems, power systems, etc.):\u003c/p\u003e\u003cul\u003e\u003cli\u003e\"Why Study Sinusoids?\": \u003ca href = \"https://www.youtube.com/watch?v=yXjXJ5OlNyQ\"\u003ehttps://www.youtube.com/watch?v=yXjXJ5OlNyQ\u003c/a\u003e\u003c/li\u003e\u003cli\u003e\"Euler's formula\": \u003ca href = \"https://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-eulers-formula\"\u003ehttps://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-eulers-formula\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eWhen working with complex numbers, sometimes it's easier to work with the \"rectangular/Cartesian form\" (z = x + j*y) and sometimes it's easier to work with the \"polar form\" (r ∠ θ).\u003c/p\u003e\u003cp\u003e\u003ci\u003eAn analogy:\u003c/i\u003e\u003c/p\u003e\u003cul\u003e\u003cli\u003eUsing the rectangular form is sometimes like using decimals: it can make the numbers easier to add / subtract\u003c/li\u003e\u003cli\u003eUsing the polar form is sometimes like using fractions: it can the numbers easier to multiply / divide\u003c/li\u003e\u003cli\u003eIn the end, the two forms are equivalent, but sometimes they're easier to work with in one form instead of another.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003e\u003cb\u003ePROBLEM DESCRIPTION\u003c/b\u003e\u003c/p\u003e\u003cp\u003eWrite a function which converts between the rectangular form and the polar form.\u003c/p\u003e\u003cp\u003eYou can view a comparison of the two forms here: \u003ca href = \"https://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-complex-numbers\"\u003ehttps://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-complex-numbers\u003c/a\u003e\u003c/p\u003e\u003cp\u003eThe variable \"form\" will be used to determine whether the function converts from rectangular to polar or from polar to rectangular.\u003c/p\u003e\u003cp\u003eThe function takes the following inputs:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\"input1\" - a variable which is either \"x\" (the real component in rectangular form) or \"r\" (the radius in polar form)\u003c/li\u003e\u003cli\u003e\"input2\" - a variable which is either \"y\" (the complex component in rectangular form) or \"theta\" (the angle, in degrees, in polar form)\u003c/li\u003e\u003cli\u003e\"form\" - a variable which is set to either \"r2p\" (to convert from rectangular to polar) or \"p2r\" (to convert from polar to rectangular)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe function will output the variable \"output\" in the form of a column vector [output1;output2] where:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\"output1\" - a component of the output which is either \"x\" (the real component in rectangular form) or \"r\" (the radius in polar form)\u003c/li\u003e\u003cli\u003e\"output2\" - a component of the output which is either \"y\" (the complex component in rectangular form) or \"theta\" (the positive angle, in degrees, in polar form)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe test suite will round the components of your output vector to 4 decimal places.\u003c/p\u003e\u003cp\u003e\u003cb\u003eFEEDBACK\u003c/b\u003e\u003c/p\u003e\u003cp\u003ePlease feel free to leave feedback on this problem in the comments!  :)\u003c/p\u003e","function_template":"function [output] = complexConverter(input1, input2, form)\r\n  % write a function which converts from rectangular to polar and polar to rectangular\r\nend","test_suite":"%%Test1\r\ninput1 = 2; %x\r\ninput2 = 2; %y\r\nform = 'r2p';\r\noutput1 = 2.8284;\r\noutput2 = 45;\r\noutput = [output1;output2];\r\nassert(isequal(round(complexConverter(input1, input2, form),4),output))\r\n%%Test2\r\ninput1 = 3; %radius\r\ninput2 = 60; %degrees\r\nform = 'p2r';\r\noutput1 = 1.5000;\r\noutput2 = 2.5981;\r\noutput = [output1;output2];\r\nassert(isequal(round(complexConverter(input1, input2, form),4),output))\r\n%%Test3\r\ninput1 = 3; %x\r\ninput2 = -4; %y\r\nform = 'r2p';\r\noutput1 = 5.0000;\r\noutput2 = 306.8699;\r\noutput = [output1;output2];\r\nassert(isequal(round(complexConverter(input1, input2, form),4),output))\r\n%%Test4\r\ninput1 = 7; %radius\r\ninput2 = 225; %degrees\r\nform = 'p2r';\r\noutput1 = -4.9497;\r\noutput2 = -4.9497;\r\noutput = [output1;output2];\r\nassert(isequal(round(complexConverter(input1, input2, form),4),output))","published":true,"deleted":false,"likes_count":2,"comments_count":4,"created_by":377536,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":31,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-01-28T03:12:54.000Z","updated_at":"2025-12-29T14:25:32.000Z","published_at":"2020-02-25T00:35:18.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eBACKGROUND / MOTIVATION:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eComplex numbers can be an important tool in an electrical engineer's toolbox because they can help us describe / work with sinusoidal signals.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSinusoidal signals can be found all over the place in day-to-day life (in music, light, communication systems, power systems, etc.):\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"Why Study Sinusoids?\\\":\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.youtube.com/watch?v=yXjXJ5OlNyQ\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.youtube.com/watch?v=yXjXJ5OlNyQ\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"Euler's formula\\\":\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-eulers-formula\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-eulers-formula\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWhen working with complex numbers, sometimes it's easier to work with the \\\"rectangular/Cartesian form\\\" (z = x + j*y) and sometimes it's easier to work with the \\\"polar form\\\" (r ∠ θ).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eAn analogy:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eUsing the rectangular form is sometimes like using decimals: it can make the numbers easier to add / subtract\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eUsing the polar form is sometimes like using fractions: it can the numbers easier to multiply / divide\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn the end, the two forms are equivalent, but sometimes they're easier to work with in one form instead of another.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ePROBLEM DESCRIPTION\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function which converts between the rectangular form and the polar form.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou can view a comparison of the two forms here:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-complex-numbers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-complex-numbers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe variable \\\"form\\\" will be used to determine whether the function converts from rectangular to polar or from polar to rectangular.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe function takes the following inputs:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"input1\\\" - a variable which is either \\\"x\\\" (the real component in rectangular form) or \\\"r\\\" (the radius in polar form)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"input2\\\" - a variable which is either \\\"y\\\" (the complex component in rectangular form) or \\\"theta\\\" (the angle, in degrees, in polar form)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"form\\\" - a variable which is set to either \\\"r2p\\\" (to convert from rectangular to polar) or \\\"p2r\\\" (to convert from polar to rectangular)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe function will output the variable \\\"output\\\" in the form of a column vector [output1;output2] where:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"output1\\\" - a component of the output which is either \\\"x\\\" (the real component in rectangular form) or \\\"r\\\" (the radius in polar form)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"output2\\\" - a component of the output which is either \\\"y\\\" (the complex component in rectangular form) or \\\"theta\\\" (the positive angle, in degrees, in polar form)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe test suite will round the components of your output vector to 4 decimal places.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eFEEDBACK\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePlease feel free to leave feedback on this problem in the comments! :)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44271,"title":"0\u003c=x\u003c=pi?","description":"Check whether the given angle is between zero and pi.\r\nReturn logical true or false.","description_html":"\u003cp\u003eCheck whether the given angle is between zero and pi.\r\nReturn logical true or false.\u003c/p\u003e","function_template":"function y = ang(x)\r\n  y = (x==pi/2);\r\nend","test_suite":"%%\r\nx = rand*pi;\r\ny_correct = (200\u003e=100);\r\nassert(isequal(ang(x),y_correct))\r\n%%\r\nx = -rand*pi;\r\ny_correct = (100\u003e=200);\r\nassert(isequal(ang(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":140,"test_suite_updated_at":"2017-08-01T23:22:04.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-08-01T23:13:05.000Z","updated_at":"2026-02-16T12:15:51.000Z","published_at":"2017-08-01T23:13:38.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCheck whether the given angle is between zero and pi. Return logical true or false.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44062,"title":"Polar Form Complex Number Entry","description":"Write a function that takes the magnitude and angle(in degrees) of a complex number and returns a complex variable. Positive angles correspond to the Counter-Clock-Wise direction.  Must return NaN if mag is negative.","description_html":"\u003cp\u003eWrite a function that takes the magnitude and angle(in degrees) of a complex number and returns a complex variable. Positive angles correspond to the Counter-Clock-Wise direction.  Must return NaN if mag is negative.\u003c/p\u003e","function_template":"function c = cp2r(mag,arg_deg)\r\n  c = ;\r\nend","test_suite":"%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = 1;\r\narg_deg=0;\r\nc_correct = 1;\r\nassert(compdist(cp2r(mag,arg_deg),c_correct)\u003c1e-12)\r\n%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = 1;\r\narg_deg=90;\r\nc_correct = i;\r\nassert(compdist(cp2r(mag,arg_deg),c_correct)\u003c1e-12)\r\n%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = 5;\r\narg_deg=-30;\r\nc_correct = 4.33012701892219e+00 - 2.50000000000000e+00i;\r\nassert(compdist(cp2r(mag,arg_deg),c_correct)\u003c1e-12)\r\n%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = -2;\r\narg_deg=-20;\r\nassert(isnan(cp2r(mag,arg_deg)))\r\n%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = 0.1;\r\narg_deg=-8000;\r\nc_correct = 17.36481776669513e-03 -  98.48077530122045e-03i;\r\nassert(compdist(cp2r(mag,arg_deg),c_correct)\u003c1e-12)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":114158,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":57,"test_suite_updated_at":"2017-02-09T18:33:39.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-02-08T16:21:38.000Z","updated_at":"2026-02-19T10:05:51.000Z","published_at":"2017-02-08T16:21:38.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function that takes the magnitude and angle(in degrees) of a complex number and returns a complex variable. Positive angles correspond to the Counter-Clock-Wise direction. Must return NaN if mag is negative.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":190,"title":"Great Circle Distance","description":"Find shortest between two points on a ball given their azimuthal and polar angles (in degrees) as well as the radius of the sphere.\r\n","description_html":"\u003cp\u003eFind shortest between two points on a ball given their azimuthal and polar angles (in degrees) as well as the radius of the sphere.\u003c/p\u003e","function_template":"function d = sphere_distance(r,a1,p1,a2,p2)\r\n  d = 1;\r\nend","test_suite":"%%\r\nassert(isequal(round(sphere_distance(100,10,50,-20,14)*10000)/10000,75.9097));\r\n\r\n%%\r\nassert(isequal(round(sphere_distance(6371e3,-97.7430608,30.267153,-74.0244265,40.6081588)*10000)/10000,2426004.8394));\r\n\r\n%%\r\nassert(isequal(round(sphere_distance(6371e3,-97.7430608,31.267153,-74.0244265,40.6081588)*10000)/10000,2364307.7819));","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":281,"test_suite_updated_at":"2012-01-31T02:47:01.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-01-31T02:38:51.000Z","updated_at":"2026-03-31T15:30:19.000Z","published_at":"2012-01-31T02:47:01.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind shortest between two points on a ball given their azimuthal and polar angles (in degrees) as well as the radius of the sphere.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":45281,"title":"A \"Complex\" Converter: Rectangular Form \u003c-\u003e Polar Form","description":"*BACKGROUND / MOTIVATION:*\r\n\r\nComplex numbers can be an important tool in an electrical engineer's toolbox because they can help us describe / work with sinusoidal signals.\r\n\r\nSinusoidal signals can be found all over the place in day-to-day life (in music, light, communication systems, power systems, etc.):\r\n\r\n* \"Why Study Sinusoids?\": \u003chttps://www.youtube.com/watch?v=yXjXJ5OlNyQ\u003e\r\n* \"Euler's formula\": \u003chttps://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-eulers-formula\u003e\r\n\r\nWhen working with complex numbers, sometimes it's easier to work with the \"rectangular/Cartesian form\" (z = x + j*y) and sometimes it's easier to work with the \"polar form\" (r ∠ θ).\r\n\r\n_An analogy:_\r\n\r\n* Using the rectangular form is sometimes like using decimals: it can make the numbers easier to add / subtract\r\n* Using the polar form is sometimes like using fractions: it can the numbers easier to multiply / divide\r\n* In the end, the two forms are equivalent, but sometimes they're easier to work with in one form instead of another.\r\n\r\n*PROBLEM DESCRIPTION*\r\n\r\nWrite a function which converts between the rectangular form and the polar form.\r\n\r\nYou can view a comparison of the two forms here:\r\n\u003chttps://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-complex-numbers\u003e\r\n\r\nThe variable \"form\" will be used to determine whether the function converts from rectangular to polar or from polar to rectangular.\r\n\r\nThe function takes the following inputs:\r\n\r\n* \"input1\" - a variable which is either \"x\" (the real component in rectangular form) or \"r\" (the radius in polar form)\r\n* \"input2\" - a variable which is either \"y\" (the complex component in rectangular form) or \"theta\" (the angle, in degrees, in polar form)\r\n* \"form\" - a variable which is set to either \"r2p\" (to convert from rectangular to polar) or \"p2r\" (to convert from polar to rectangular)\r\n\r\nThe function will output the variable \"output\" in the form of a column vector [output1;output2] where:\r\n\r\n* \"output1\" - a component of the output which is either \"x\" (the real component in rectangular form) or \"r\" (the radius in polar form)\r\n* \"output2\" - a component of the output which is either \"y\" (the complex component in rectangular form) or \"theta\" (the positive angle, in degrees, in polar form)\r\n\r\nThe test suite will round the components of your output vector to 4 decimal places.\r\n\r\n*FEEDBACK*\r\n\r\nPlease feel free to leave feedback on this problem in the comments!  :)","description_html":"\u003cp\u003e\u003cb\u003eBACKGROUND / MOTIVATION:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eComplex numbers can be an important tool in an electrical engineer's toolbox because they can help us describe / work with sinusoidal signals.\u003c/p\u003e\u003cp\u003eSinusoidal signals can be found all over the place in day-to-day life (in music, light, communication systems, power systems, etc.):\u003c/p\u003e\u003cul\u003e\u003cli\u003e\"Why Study Sinusoids?\": \u003ca href = \"https://www.youtube.com/watch?v=yXjXJ5OlNyQ\"\u003ehttps://www.youtube.com/watch?v=yXjXJ5OlNyQ\u003c/a\u003e\u003c/li\u003e\u003cli\u003e\"Euler's formula\": \u003ca href = \"https://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-eulers-formula\"\u003ehttps://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-eulers-formula\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eWhen working with complex numbers, sometimes it's easier to work with the \"rectangular/Cartesian form\" (z = x + j*y) and sometimes it's easier to work with the \"polar form\" (r ∠ θ).\u003c/p\u003e\u003cp\u003e\u003ci\u003eAn analogy:\u003c/i\u003e\u003c/p\u003e\u003cul\u003e\u003cli\u003eUsing the rectangular form is sometimes like using decimals: it can make the numbers easier to add / subtract\u003c/li\u003e\u003cli\u003eUsing the polar form is sometimes like using fractions: it can the numbers easier to multiply / divide\u003c/li\u003e\u003cli\u003eIn the end, the two forms are equivalent, but sometimes they're easier to work with in one form instead of another.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003e\u003cb\u003ePROBLEM DESCRIPTION\u003c/b\u003e\u003c/p\u003e\u003cp\u003eWrite a function which converts between the rectangular form and the polar form.\u003c/p\u003e\u003cp\u003eYou can view a comparison of the two forms here: \u003ca href = \"https://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-complex-numbers\"\u003ehttps://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-complex-numbers\u003c/a\u003e\u003c/p\u003e\u003cp\u003eThe variable \"form\" will be used to determine whether the function converts from rectangular to polar or from polar to rectangular.\u003c/p\u003e\u003cp\u003eThe function takes the following inputs:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\"input1\" - a variable which is either \"x\" (the real component in rectangular form) or \"r\" (the radius in polar form)\u003c/li\u003e\u003cli\u003e\"input2\" - a variable which is either \"y\" (the complex component in rectangular form) or \"theta\" (the angle, in degrees, in polar form)\u003c/li\u003e\u003cli\u003e\"form\" - a variable which is set to either \"r2p\" (to convert from rectangular to polar) or \"p2r\" (to convert from polar to rectangular)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe function will output the variable \"output\" in the form of a column vector [output1;output2] where:\u003c/p\u003e\u003cul\u003e\u003cli\u003e\"output1\" - a component of the output which is either \"x\" (the real component in rectangular form) or \"r\" (the radius in polar form)\u003c/li\u003e\u003cli\u003e\"output2\" - a component of the output which is either \"y\" (the complex component in rectangular form) or \"theta\" (the positive angle, in degrees, in polar form)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThe test suite will round the components of your output vector to 4 decimal places.\u003c/p\u003e\u003cp\u003e\u003cb\u003eFEEDBACK\u003c/b\u003e\u003c/p\u003e\u003cp\u003ePlease feel free to leave feedback on this problem in the comments!  :)\u003c/p\u003e","function_template":"function [output] = complexConverter(input1, input2, form)\r\n  % write a function which converts from rectangular to polar and polar to rectangular\r\nend","test_suite":"%%Test1\r\ninput1 = 2; %x\r\ninput2 = 2; %y\r\nform = 'r2p';\r\noutput1 = 2.8284;\r\noutput2 = 45;\r\noutput = [output1;output2];\r\nassert(isequal(round(complexConverter(input1, input2, form),4),output))\r\n%%Test2\r\ninput1 = 3; %radius\r\ninput2 = 60; %degrees\r\nform = 'p2r';\r\noutput1 = 1.5000;\r\noutput2 = 2.5981;\r\noutput = [output1;output2];\r\nassert(isequal(round(complexConverter(input1, input2, form),4),output))\r\n%%Test3\r\ninput1 = 3; %x\r\ninput2 = -4; %y\r\nform = 'r2p';\r\noutput1 = 5.0000;\r\noutput2 = 306.8699;\r\noutput = [output1;output2];\r\nassert(isequal(round(complexConverter(input1, input2, form),4),output))\r\n%%Test4\r\ninput1 = 7; %radius\r\ninput2 = 225; %degrees\r\nform = 'p2r';\r\noutput1 = -4.9497;\r\noutput2 = -4.9497;\r\noutput = [output1;output2];\r\nassert(isequal(round(complexConverter(input1, input2, form),4),output))","published":true,"deleted":false,"likes_count":2,"comments_count":4,"created_by":377536,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":31,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-01-28T03:12:54.000Z","updated_at":"2025-12-29T14:25:32.000Z","published_at":"2020-02-25T00:35:18.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eBACKGROUND / MOTIVATION:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eComplex numbers can be an important tool in an electrical engineer's toolbox because they can help us describe / work with sinusoidal signals.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSinusoidal signals can be found all over the place in day-to-day life (in music, light, communication systems, power systems, etc.):\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"Why Study Sinusoids?\\\":\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.youtube.com/watch?v=yXjXJ5OlNyQ\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.youtube.com/watch?v=yXjXJ5OlNyQ\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"Euler's formula\\\":\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-eulers-formula\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-eulers-formula\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWhen working with complex numbers, sometimes it's easier to work with the \\\"rectangular/Cartesian form\\\" (z = x + j*y) and sometimes it's easier to work with the \\\"polar form\\\" (r ∠ θ).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eAn analogy:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eUsing the rectangular form is sometimes like using decimals: it can make the numbers easier to add / subtract\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eUsing the polar form is sometimes like using fractions: it can the numbers easier to multiply / divide\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn the end, the two forms are equivalent, but sometimes they're easier to work with in one form instead of another.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ePROBLEM DESCRIPTION\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function which converts between the rectangular form and the polar form.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou can view a comparison of the two forms here:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-complex-numbers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-complex-numbers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe variable \\\"form\\\" will be used to determine whether the function converts from rectangular to polar or from polar to rectangular.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe function takes the following inputs:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"input1\\\" - a variable which is either \\\"x\\\" (the real component in rectangular form) or \\\"r\\\" (the radius in polar form)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"input2\\\" - a variable which is either \\\"y\\\" (the complex component in rectangular form) or \\\"theta\\\" (the angle, in degrees, in polar form)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"form\\\" - a variable which is set to either \\\"r2p\\\" (to convert from rectangular to polar) or \\\"p2r\\\" (to convert from polar to rectangular)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe function will output the variable \\\"output\\\" in the form of a column vector [output1;output2] where:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"output1\\\" - a component of the output which is either \\\"x\\\" (the real component in rectangular form) or \\\"r\\\" (the radius in polar form)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\"output2\\\" - a component of the output which is either \\\"y\\\" (the complex component in rectangular form) or \\\"theta\\\" (the positive angle, in degrees, in polar form)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe test suite will round the components of your output vector to 4 decimal places.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eFEEDBACK\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePlease feel free to leave feedback on this problem in the comments! :)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44271,"title":"0\u003c=x\u003c=pi?","description":"Check whether the given angle is between zero and pi.\r\nReturn logical true or false.","description_html":"\u003cp\u003eCheck whether the given angle is between zero and pi.\r\nReturn logical true or false.\u003c/p\u003e","function_template":"function y = ang(x)\r\n  y = (x==pi/2);\r\nend","test_suite":"%%\r\nx = rand*pi;\r\ny_correct = (200\u003e=100);\r\nassert(isequal(ang(x),y_correct))\r\n%%\r\nx = -rand*pi;\r\ny_correct = (100\u003e=200);\r\nassert(isequal(ang(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":140,"test_suite_updated_at":"2017-08-01T23:22:04.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-08-01T23:13:05.000Z","updated_at":"2026-02-16T12:15:51.000Z","published_at":"2017-08-01T23:13:38.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCheck whether the given angle is between zero and pi. Return logical true or false.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":44062,"title":"Polar Form Complex Number Entry","description":"Write a function that takes the magnitude and angle(in degrees) of a complex number and returns a complex variable. Positive angles correspond to the Counter-Clock-Wise direction.  Must return NaN if mag is negative.","description_html":"\u003cp\u003eWrite a function that takes the magnitude and angle(in degrees) of a complex number and returns a complex variable. Positive angles correspond to the Counter-Clock-Wise direction.  Must return NaN if mag is negative.\u003c/p\u003e","function_template":"function c = cp2r(mag,arg_deg)\r\n  c = ;\r\nend","test_suite":"%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = 1;\r\narg_deg=0;\r\nc_correct = 1;\r\nassert(compdist(cp2r(mag,arg_deg),c_correct)\u003c1e-12)\r\n%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = 1;\r\narg_deg=90;\r\nc_correct = i;\r\nassert(compdist(cp2r(mag,arg_deg),c_correct)\u003c1e-12)\r\n%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = 5;\r\narg_deg=-30;\r\nc_correct = 4.33012701892219e+00 - 2.50000000000000e+00i;\r\nassert(compdist(cp2r(mag,arg_deg),c_correct)\u003c1e-12)\r\n%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = -2;\r\narg_deg=-20;\r\nassert(isnan(cp2r(mag,arg_deg)))\r\n%%\r\ncompdist = @(a,b) abs(a-b);\r\nmag = 0.1;\r\narg_deg=-8000;\r\nc_correct = 17.36481776669513e-03 -  98.48077530122045e-03i;\r\nassert(compdist(cp2r(mag,arg_deg),c_correct)\u003c1e-12)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":114158,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":57,"test_suite_updated_at":"2017-02-09T18:33:39.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-02-08T16:21:38.000Z","updated_at":"2026-02-19T10:05:51.000Z","published_at":"2017-02-08T16:21:38.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function that takes the magnitude and angle(in degrees) of a complex number and returns a complex variable. Positive angles correspond to the Counter-Clock-Wise direction. Must return NaN if mag is negative.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":190,"title":"Great Circle Distance","description":"Find shortest between two points on a ball given their azimuthal and polar angles (in degrees) as well as the radius of the sphere.\r\n","description_html":"\u003cp\u003eFind shortest between two points on a ball given their azimuthal and polar angles (in degrees) as well as the radius of the sphere.\u003c/p\u003e","function_template":"function d = sphere_distance(r,a1,p1,a2,p2)\r\n  d = 1;\r\nend","test_suite":"%%\r\nassert(isequal(round(sphere_distance(100,10,50,-20,14)*10000)/10000,75.9097));\r\n\r\n%%\r\nassert(isequal(round(sphere_distance(6371e3,-97.7430608,30.267153,-74.0244265,40.6081588)*10000)/10000,2426004.8394));\r\n\r\n%%\r\nassert(isequal(round(sphere_distance(6371e3,-97.7430608,31.267153,-74.0244265,40.6081588)*10000)/10000,2364307.7819));","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":281,"test_suite_updated_at":"2012-01-31T02:47:01.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-01-31T02:38:51.000Z","updated_at":"2026-03-31T15:30:19.000Z","published_at":"2012-01-31T02:47:01.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind shortest between two points on a ball given their azimuthal and polar angles (in degrees) as well as the radius of the sphere.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"polar\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"polar\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"polar\"","","\"","polar","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f1051b02260\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f1051b021c0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f1051b015e0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f1051b026c0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f1051b02620\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f1051b024e0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f1051b023a0\u003e":"tag:\"polar\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f1051b023a0\u003e":"tag:\"polar\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"search","password":"J3bGPZzQ7asjJcCk","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"polar\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"polar\"","","\"","polar","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f1051b02260\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f1051b021c0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f1051b015e0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f1051b026c0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f1051b02620\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f1051b024e0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f1051b023a0\u003e":"tag:\"polar\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f1051b023a0\u003e":"tag:\"polar\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":45281,"difficulty_rating":"easy"},{"id":44271,"difficulty_rating":"easy"},{"id":44062,"difficulty_rating":"easy"},{"id":190,"difficulty_rating":"medium"}]}}