Mat(3,2) = (M + Kp + A) / (1 + 1/beta);
Mat(3,3) = 0.5*A/(1 + 1/beta);
Mat(3,4) = -Gr/(1 + 1/beta);
Mat(3,6) = -Gc/(1 + 1/beta);
Mat(5,5) = Pr*0.5*A/(1 - Pr*Df*Sc*Sr);
Mat(5,6) = - Pr*Df*Sc*(2*A - L0) / (1 - Pr*Df*Sc*Sr);
Mat(5,7) = - Pr*Df*Sc*0.5*A/ (1 - Pr*Df*Sc*Sr);
Mat(7,4) = - Sr*Pr*2*A / (1 - Sr*Df*Pr);
Mat(7,5) = - Sr*Pr*0.5*A / (1 - Sr*Df*Pr);
Mat(7,7) = Sc*(0.5*A+2*A) / (1 - Sr*Df*Pr);
syms x1(t) x2(t) x3(t) x4(t) x5(t) x6(t) x7(t)
eqns = [diff(x1);diff(x2);diff(x3);diff(x4);diff(x5);diff(x6);diff(x7)]-Mat*[x1;x2;x3;x4;x5;x6;x7]==[0;0;0;0;0;0;0];
sol = dsolve(eqns,'MaxDegree',4)
eqn1 = subs(sol.x2,t,0)-(1+K0*subs(sol.x3,t,0))==0;
eqn2 = subs(sol.x5,t,0)+Bi1*(1-subs(sol.x4,t,0))==0;
eqn3 = subs(sol.x7,t,0)+Bi2*(1-subs(sol.x6,t,0))==0;
eqn4 = subs(sol.x2,t,10)==0;
eqn5 = subs(sol.x4,t,10)==0;
eqn6 = subs(sol.x6,t,10)==0;
eqn7 = subs(sol.x7,t,10)==0;
[A,b] = equationsToMatrix([eqn1,eqn2,eqn3,eqn4,eqn5,eqn6,eqn7])
b =