Complete the following in MATLAB Write a script that takes u

Complete the following in MATLAB. Write a script that takes user input about at least two vectors, add the vectors and gives the output. The output should contain following: 1. a. b. c. d. x and y components for each vector resultant force direction of the resultant force measured CCW from the +x-axis. Use the fprintf for all outputs.

Solution

Script

n = input(\'Enter how many row vectors you want to give\')

for i = 1:n

f(i,:) = input (\'Enter row vector\');

temp = f(i,:);

fprintf(\'x component %d,y component %d\ ,\'temp(1),temp(2));

end

x_res = sum(f(:,1)); %sum of all x components

y_res = sum(f:,2)); %sum of all y components

mag = sqrt((x_res^2)+(y_res^2));%magnitude of all vectors(resultant)

dir = angle(x_res+(y_res*1i));%direction of resultant vector

fprintf(\'resultant force %d\ \'mag);

fprintf(\'direction %d\ ,\'dir);

Output:

Enter how many row vectors you want to give >2

n = 2

Enter row vector> [1 2]

x component 1,y component 2

Enter row vector> [-1 2]

x component -1, y component 2

resultant force 4direction 1.5708 octave:2> source(\"force_res.m\")

Enter how many row vectors you want to give> iuewfiues

error: \'iuewfiues\' undefined near line 1 column 1

error: called from

force_res at line 1 column 3

octave:2> source (\"force_res.m\")

Enter how many row vectors you want to give>3

n = 3

Enter row vector> [-1 2]

x component -1,y componnt 2

Enter row vector> [2 -1]

x component 2,y component -1

Enter row vector> [4 5]

x component 4,y component 5

resultant force 7.81025

direction 0.876058

 Complete the following in MATLAB. Write a script that takes user input about at least two vectors, add the vectors and gives the output. The output should cont
 Complete the following in MATLAB. Write a script that takes user input about at least two vectors, add the vectors and gives the output. The output should cont

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site