This must be done as function in MATLAB Function Description: You have been give
ID: 3883791 • Letter: T
Question
This must be done as function in MATLAB
Function Description: You have been given the (x, y) coordinates of the two players on the football field, represented by a vector, where each coordinate is listed in the order [x1, y1, x2, y2]. Use your newly acquired MATLAB skillz to concisely state the distance between the two players as a string! Your output string should be in the following format: ( ) is units from ( ). In case you forgot, the Euclidean distance formula between two points is: d = Squareroot (x_1 - x_2)^2 + (y_1 - y_2)^2 Example: [out] = goLong ([7 8 6 5]) out = (7.00, 8.00) is 3.16 units from (6.00, 5.00).Explanation / Answer
For this problem create 2 matlab files with .m extension named as 1.main.m 2.distance.m
the code in main.m file:
function distance=goLong(x1,y1,x2,y2)
d1=(x2-x1);
d2=(y2-y1);
distance=sqrt((d1*d1)+(d2*d2));
disp('distance between two players is:');
disp(distance);
The code in distance.m file:
function distance=goLong(x1,y1,x2,y2)
d1=(x2-x1);
d2=(y2-y1);
distance=sqrt((d1*d1)+(d2*d2));
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.