Fitting Titration Data with an Implicit Function
조회 수: 2 (최근 30일)
이전 댓글 표시
I want to fit my data to the following model:
[H+] =Bo*Vo/(Vo+Va) + kw/[H+] + [H+]*k1*Co*Vo/(([H+]^2 + k1*[H+]+k1*k2)*(Vo+Va) + 2*k1*k2*Co*Vo/(([H+]^2+k1*[H+]+k1*k2)*(Vo+Va) + Ao*Va/(Vo+Va);
where Ao, Bo, Co, Vo, kw are all known and the independent variable is Va.
I have data giving me values of Va and [H+], but I am stuck trying to figure out how to do nonlinear regression with an implicit function
Here is my code so far:
if true
lowerBound = [0 0]; %[A B]
upperBound = [10 10];
lsqoptions = optimset('MaxFunEvals',10000000,'MaxIter',10000000,'TolFun',1E-12);
[coeffs, resnorm, residual] = lsqcurvefit(@Titration_Model, initial_ks, x, CleanData, lowerBound, upperBound, lsqoptions);
end
and my function is:
if true
function H = Titration_Model(coeffs,xdata)
Bo = 0.00075;
Vo = 0.03;
Va = xdata;
kw = 1E-14;
Co = 0.000234;
Ao = 0.05;
H = -Bo*Vo/(Vo+Va(i))+kw/H+H*coeffs(1)*Co*Vo/((H^2 ...
+coeffs(1)*H+coeffs(1)*coeffs(2))*(Vo+Va(i))) + 2*coeffs(1)*coeffs(2)*Co*Vo/...
((H^2+coeffs(1)*H+coeffs(1)*coeffs(2))*(Vo+Va(i)))+Ao*Va(i)/(Vo+Va(i));
end
Any assistance would be appreciated
댓글 수: 0
답변 (1개)
Star Strider
2017년 2월 7일
It would be helpful to know the equation(s) you began with. If I remember my chemical kinetics correctly, you should be able to isolate the hydrogen ion concentration on one side of the equation.
In any event, do not subscript ‘Va’, and do element-wise operations (with the dot (.) operator) unless you intend to do matrix operations.
Example:
H = H-Bo*Vo./(Vo+Va)+kw./H+H.*coeffs(1).*Co.*Vo./((H.^2 ...
+coeffs(1).*H+coeffs(1).*coeffs(2)).*(Vo+Va(i))) + 2*coeffs(1).*coeffs(2).*Co*Vo./...
((H.^2+coeffs(1).*H+coeffs(1).*coeffs(2)).*(Vo+Va))+Ao.*Va./(Vo+Va);
You may not need vectorise every operation, but it can help.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!