% this is example 1.9.4 page 121: solving problems in chem % they are wrong disp('column 1 is methane') disp('column 2 is ammonia') disp('column 3 is water') disp('column 4 is glycine') disp('column 5 is diatomic hydrogen') disp(' ') disp('here are the number of atoms in each molecule') disp('row 1 is hydrogen') % 4*a + 3*b + 2*c = 5*d + 2*e disp('row 2 is carbon') % a=2*d; disp('row 3 is oxygen') % c=2*d; disp('row 4 is nitrogen') % b=d; disp('note - the negative values indicate transposition from right side') mm= [ 4 3 2 -5 -2 1 0 0 -2 0 0 0 1 -2 0 0 1 0 -1 0 ] mm2=rref(mm) [n,d]=rat(mm2(:,5)) disp('2 parts methane + 1 part ammonia + 2 parts water') disp('gives 1 part glycine and 5 parts molecular hydrogen')