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

Write a MATLAB program to compute the sum of two 2-D vectors. You will prompt th

ID: 3802222 • Letter: W

Question

Write a MATLAB program to compute the sum of two 2-D vectors. You will prompt the user to input the x and y components of two vectors (four inputs). Then your program will compute the x and y components of the resultant and then the magnitude and the direction of the resultant. Last, your program should display the x and y components, plus the magnitude and direction for the polar coordinates. The flowchart for the program is shown below.

The information displayed back to the user should be in the following format where your program will fill in the blanks with the computed information:

The x and y components of the resultant vector are _____ and _____, respectively

Start Prompt the user to input the X-component of Vector 1, Save as: F1x Prompt the user to input the y-component of Vector 1, Save as: F1y Prompt the user to input the X-component of Vector 2, Save as: F2x Prompt the user to input the y-component of Vector 2, Save as: F2y Compute the x-compoent of the resultant vector Compute the y-compoent of the resultant vector Compute the magnitude of the resultant vector Compute the direction of the resultant vector Display the x and y components of the resultant vector Display the magnitude and direction of the resultant vector End

Explanation / Answer

x1=input("enter x component of vector 1 :")
y1=input("enter y component of vector 1 :")
x2=input("enter x component of vector 2 :")
y2=input("enter y component of vector 2 :")
x3=x1+x2
y3=y1+y2
mag=sqrt(((x1-x2)^2)+((y1-y2)^2))
direction=atan((y2-y1)/(x2-x1))
fprintf(' x component :%f',x3)
fprintf(' y component :%f',y3)
fprintf(' magnitude of resultant :%f',mag)
fprintf(' direction is :%f',direction*180/3.14)

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