k = 1.38e-23;
q = 1.602e-19;
T = 25+273;
Ns = 36;
a1 = 2.4;
a2 = 21.8;
a3 = 17.2;
a4 = 2.20;
a5 = (Ns*k*T)/q;
x0 = [2.4, 1.2e-7, 1.5, 0.5, 600];
lb = [2, 1e-7, 1.3, 0.3, 400];
ub = [2.6, 5e-7, 1.7, 0.7, 900];
x = lsqnonlin(@(x)myfun(x, a1, a2, a3, a4, a5), x0, lb, ub);
function f = myfun(x, a1, a2, a3, a4, a5)
x1 = x(1);
x2 = x(2);
x3 = x(3);
x4 = x(4);
x5 = x(5);
f(1) = x1-x2*(exp((x4*a1)/(x3*a5))-1)-((x4*a1)/x5)-a1;
f(2) = x2*(exp(a2/(x3*a5))-1)+(a2/x5)-x1;
f(3) = x1-x2*(exp((a3+x4*a4)/(x3*a5))-1)-((a3+x4*a4)/x5)-a4;
f(4) = a3*(((x2/(x3*a5))*exp((a3+x4*a4)/(x3*a5))+(1/x5))/(1+((x4*x2)/(x3*a5))*exp((a3+x4*a4)/(x3*a5))+(x4/x5)))-a4;
f(5) = (((x2/(x3*a5))*exp((x4*a1)/(x3*a5))+(1/x5))/(1+((x4*a1)/(x3*a5))*exp((x4*a1)/(x3*a5))+(x4/x5)))-(1/x5);
end
Best Answer