Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How to do this function in matlab duhaccess/content/attachment/c5 0.05 Problem 4

ID: 2079746 • Letter: H

Question



How to do this function in matlab

duhaccess/content/attachment/c5 0.05 Problem 4.2 Two distances are required to specify the location of a point relative to an origin in two- dimensional space The horizontal and vertical distances (x, y) in Cartesian coordinates. The radius and angle (r, 0) in polar coordinates. It is relatively straightforward to compute Cartesian coordinates (r. J) on the basis of polar coordinates (r. 0). The reverse process is not so simple. The radius can be computed by the following formula

Explanation / Answer

Matlab Code:

function [r theta]=f_l_cart2pol(x,y)
r = sqrt((x^2)+(y^2));
if x>0
theta = atand(y/x);
elseif x<0 && y>0
theta = atand(y/x)+180;
elseif x<0 && y<0
theta = atand(y/x)-180;
elseif x<0 && y==0
theta = 180;
elseif x==0 && y>0
theta = 90;
elseif x==0 && y<0
theta = -90;
elseif x==0 && y==0
theta = 0;
end
end

command window output:

>> [r t] = f_l_cart2pol(0,3)

r =

3


t =

90

>>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote