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.02Explanation / 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:
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.