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

A vector is a mathematical quantity that has both magnitude and direction. It ca

ID: 3603449 • Letter: A

Question

A vector is a mathematical quantity that has both magnitude and direction. It can be represented as a displacement along the T and y axes in rectangular coordinates or by a distance Y at an angle in polar coordinates. The conversion between polar and rectangular es is carried out using the following equations: x = r cos y = r sin Write a MATLAB code that will accept two vectors defined in polar coordinates, convert them to rectangular coordinates and then subtract the second vector from the first. Your output should be the resultant values of X- X1 - 22 and Yy1-/2. Display the result as follows: fprintf'%.2An'x) fprintf('962f',Y) For example: Test Result r=[35]; th = [1 2]. 3.70 -2.02

Explanation / Answer

Program in matlab:

r = [3 5];
th = [1 2];
for i = 1:2
x(i) =r(i)*cos(th(i)); -- iterating in for loop to get x1,x2,y2,y2 values
y(i) =r(i)*sin(th(i));
end
X=x(1)-x(2); -- calculating resultant values
Y=y(1)-y(2);
fprintf('X : %.2f ',X); -- printing resultant values
fprintf('Y : %.2f ',Y);

output: