Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

X = [ 2 , 2 , 0 , - 3 , 0 ] ; Y = [ 0 . 5 , 1 . 1

X =[2,2,0,-3,0];
Y =[0.5,1.15,2,1.25,-1.5];
r = zeros(size(X));
theta = zeros(size(X));
lenX = length(X);
AngFact =180/pi;
for i =1:lenX
if (X(i)>0 && Y(i)>0)
r(i)= sqrt(X(i)^2+ Y(i)^2);
theta(i)= atan(Y(i)/ X(i));
theta(i)= AngFact * theta(i);
elseif (X(i)<0 && Y(i)>0)
r(i)= sqrt(X(i)^2+ Y(i)^2);
theta(i)= atan(Y(i)/ X(i))+ pi;
theta(i)= AngFact * theta(i);
elseif (X(i)<0 && Y(i)<0)
r(i)= sqrt(X(i)^2+ Y(i)^2);
theta(i)= atan(Y(i)/ X(i))- pi;
theta(i)= AngFact * theta(i);
elseif (X(i)<0 && Y(i)==0)
r(i)= sqrt(X(i)^2+ Y(i)^2);
theta(i)= pi;
theta(i)= AngFact * theta(i);
elseif (X(i)==0 && Y(i)>0)
r(i)= sqrt(X(i)^2+ Y(i)^2);
theta(i)= pi/2;
theta(i)= AngFact * theta(i);
elseif (X(i)==0 && Y(i)<0)
r(i)= sqrt(X(i)^2+ Y(i)^2);
theta(i)=-pi/2;
theta(i)= AngFact * theta(i);
else
r(i)=0;
theta(i)=0;
end
end
% Print the Outputs.
disp('The x-coordinate values:');
disp(X);
fprintf('
The y-coordinate values:');
disp(Y);
fprintf('
The r-coordinate values:');
disp(r);
fprintf('
The theta (in degrees) values:');
disp(theta);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions