Computers and Technology

Write a matlab program that uses matrix multiplication to calculate the center of mass of any spacecraft, provided the coordinates and masses of each component are defined in an input file. For example, the input file for the above example would look like:0.1 2.0 3.0 3.501.0 1.0 1.0 1.501.5 0.2 0.5 0.792.0 2.0 4.0 1.75Your program should display the center of mass to the screen for the user and graph the location of the center of mass and the locations of all components of the system. All points should be appropriately labeled and the graph should use good practices for labeling, etc. (Use the plot3 function for graphing).Background info:The mass of a vehicle and the location of its center of gravity is very important to space flight. One reason that it is important is that rockets tumble if the center of pressure is forward of the center of gravity. The location of the center of gravity of a system can be calculated from its component masses in a 3-D rectangular coordinate system, as RM x mi x m x3m3 xim, xin m, (Eqn. 1) y M yim y2m2 z m where i, y, and are the coordinates of the center of gravity; M 1m is the total mass of the system, xi toxin are the x-coordinates of each component (1 to n respectively); y to yn are the y-coordinates for each components zu to zn are the z-coordinates of each component, and m to mn are the masses of each component. For example, consider a vehicle with the following component locations and masses (only a limited set is shown for example tractability) component (x, y, z) meters (0.1, 2.0, 3.0) bolt 3.50 (1.0, 1.0, 1.0) 1.50 (1.5, 0.2, 0.5) 0.79 bracket 0.2.0, 4.0 75 Solving for X in the equation 1 thex-coordinate of the center of gravity is (Eqn. 4) The y- and z-coordinates for the center of gravity can be determined similarly. The X 1xum term in equation 4 is the dot product of a vector containing the x-coordinates of each component x x1, x2, x] and a vector containing the masses of each component m [mu, m2, mn]. Hence, matrix multiplication can be used to calculate all coordinates of the center of gravity simultaneously, as C Cm mu, where c (x, y, z) is the geometric vector that contains the coordinates of the center of gravity and Cis an appropriately defined matrix that holds the values of the component coordinates