Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

7.1: Balance Chemical Equations 1 by a third party Though your activity may be 0

ID: 3746019 • Letter: 7

Question

7.1: Balance Chemical Equations 1 by a third party Though your activity may be 0/20 recorded, a page refresh may be needed to fill the banner Balance Chemical Equations 1 Write a function BalanceChemical to balance chemical reactions by solving a linear set of equations. The inputs arguments are: 1. Reagents: Symbols of reagents in string row array 2. Products: Symbols of products in string row array 3. Elements: Elements in the reaction in string row array 4. EICmpReag: Elemental composition of reactants in two dimensional numeric array 5. EiCmpPrdcts: Elemental composition of prducts in two dimensional numeric array Hint: The first part of the problem is setting up the set of linear equations that should be solve. The second part of the problem is to find the integers from the solution. One way to do this is to mulitiply the rational basis for the nullspace by increasing larger integers untl both the let- and right-side integers exist. For example, for the reaction that involves CHs reacting with 02 to produce CO, and HO: "O2"); ["CO2", ["C",'W", "O"1 Reagents: ["CH4", ElCmpReag [1,4,8 Products "H20"); Elements ,0,2); where the first row corresponds to elements in Reagents (1). 2nd to Reagents(2), etc. given in the order specified by Elements ElCmpPrdcts 11,8,2; where the first row corresponds to Products (1). 2nd to Products (2), etc. given in the order specified by Elements. The outputs arguments are: 1. leftsidelntegers: Left-side integers of reactants to balance the equation 2. rightsidelnteger: Right-side integers products to balance the equation 3. coefMat: The coefficient matrix that was composed to balance the equation For example, balance CHs+0,-Co,+H.0 >>Reagents ["CH4", "O2"]; Products-["CO2"' ..H20"); »Elements "CHO";ELCmpReag 11,4,8:,e,21: ElCmpPrdcts [1,0,2:0,2,1] o[leftsideIntegers, rightsideIntegers, coefMatBalanceChemical (Reagents,Products, Elements,ElCepReag, E LeftsideIntegers 1x2 uint8 row vector

Explanation / Answer

% create a function of balance chemical equation function [leftsideIntegers,rightsideIntegers,coefMat]=BalanceChemical(Reagents,Products,Elements,ElCmpReag,ElCmpPrdcts)
%find out the coefficient of matrix
coefMat=[ElCmpReag' -ElCmpPrdcts'];
% find out the number of reagents in the chemical reaction
[red_num,~]=size(ElCmpReag);
% reduced the echeleon form
ech_form=rref(coefMat);
% select the last column vector from the matrix
vect=ech_form(:,4);
% initial the free variable
free_var=1;
% check out the variable is free or not
while(1)
% when all variable is equal to last column vector
if(all(floor(vect)==vect))
% break from the program
break;
% otherwise
else
% add up the function from
free_var=free_var+1;
%multiply vector with t
vect=free_var*vect;
% end of if-else part
end
% end of while
end
% compute the vector value
vect=[abs(vect') free_var];
% display the result of left side integer equation
leftsideIntegers=vect(1:red_num);
% display the right hand side integer equation
rightsideIntegers=vect(red_num+1:length(vect));
% end of the function
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote