Solve using matlab code Write a Matlab function called GaussPivot that performs
ID: 3028012 • Letter: S
Question
Solve using matlab code Write a Matlab function called GaussPivot that performs Gaussian elimination with partial pivoting to solve the matrix problem Ax=b. The input should be matrices A and b and the output should be solution vector x. Debug the program and write a script to confirm that it gives the correct results for the problem on the following page. When balancing the following chemical reaction by conserving the number of atoms of each element between reactants and products: (Cr(N_2H_4CO)_6))_4 (Cr(CN)_6))_3, + aKMnO_4 + bH_2SO4 rightarrow cK_2Cr_2O_7 + dMnSO_4 + eCO_2 + fKNO_3 + gK_2SO_4 + hHO_2 the unknown stoichiometric coefficients a through h are given by the solution of the following system of equations: [0 0 2 0 0 0 0 0 0 0 0 0 0 1 0 0 0 -2 0 0 0 0 0 2 0 0 0 0 1 0 0 0 -4 -4 7 4 2 3 4 1 -1 0 2 0 0 1 2 0 -1 0 01 0 0 0 0 0 0 -1 0 1 0 0 1 0][a b c d e f g h] = [7 66 96 42 24 0 0 0]Explanation / Answer
A=[0 0 2 0 0 0 0 0;0 0 0 0 0 1 0 0;0 -2 0 0 0 0 0 2;0 0 0 0 1 0 0 0;-4 -4 7 4 2 3 4 1;-1 0 2 0 0 1 2 0; -1 0 0 1 0 0 0 0 ;0 -1 0 1 0 0 1 0]
B=[7 66 96 42 24 0 0 0]
linsolve(A,B')
ans =
117.6000
139.9000
3.5000
117.6000
42.0000
66.0000
22.3000
187.9000