rite a MATLAB script that will import an Excel File containi
rite a MATLAB script that will import an Excel File containing vector information, and then compute the resultant vector by adding up the vector components of the vectors in the input file. Your code will read in magnitudes and directions for all the vectors where the first column in the spreadsheet contains the magnitudes, and the second column contains the directions. Each row is one vector and an example of how the excel spreadsheet will be assembled for a 5 vector system is shown below:
Solution
clear
 close all
 clc
 vecdata = xlsread(\'USERINPUTFILENAME.xlsx\'); // Use here user input file name
 for i = 1:size(vecdata,1)
 x(i) = vecdata(i,1)*cosd(vecdata(i,2));
 y(i) = vecdata(i,1)*sind(vecdata(i,2));
 end
 x1(1) = 0;
 y1(1) = 0;
 for i = 2:size(vecdata,1)+1
 x1(i) = x1(i-1) + x(i-1);
 y1(i) = y1(i-1) + y(i-1);
 end
 plot(x1,y1)
 hold on
 plot ([0 x1(end)], [0 y1 (end)], \'r\')
 hold off
 xlabel(\'Force in X-Direction(F_X) [N]\')
 ylabel(\'Force in Y-Direction(F_Y) [N]\')
 legend(\'System of force vectors\',\'Resultant Force\')

