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
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
>>
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.