how to minimize a parameter
古いコメントを表示
Hi, mi programm is this one
function theoretical1
clc;
clear all;
close all;
tau1=147;
k0=[150000 1.5 1.5 1.5];
nu=[-1; -5 ;-6]; % stoichiometrical matrix of coefficients
C01 = [0.00005 0.001 0.05]; % initial concentratio of measure j
[time1,C1]= ode45(@myode1,[0 tau1],C01);
function dC1dt=myode1(t,C)
R1=k0(1)*C(1)^k0(2)*C(2)^k0(3)*C(3)^k0(4);
r1=nu*R1;
dC1dt=r1;
end
%Volume
V=0.5;
%species A B and C refer to KIO3 KI and H
%Test one
load ('prova1.mat','seconds','absorbance')
csi1_1=0.2276*absorbance/1000; %in mol/L (M)
sec_1=seconds;
%Initial Concentrations
C0_1=[0.00005 0.001 0.05]; %species A,B and C
C0_A_1=C0_1(1); %conc OF IO3- in mol/L
C0_B_1=C0_1(2); %conc OF I- in mol/L
C0_C_1=C0_1(3); %conc OF H+ in mol/L
%Concentration in time
%from excel plot we know that there is a correlation between absorbance and
%the concentration of I2 that follows a linear rule as follows: C=0.081*A
C_A_1=C0_A_1-csi1_1;
CI2_1=absorbance*0.081/1000;
csi2_1=3*csi1_1-CI2_1; %mol/L
C_B_1=C0_B_1-5*csi1_1-csi2_1;
C_C_1=C0_C_1-6*csi1_1;
C_exp_1=[C_A_1 C_B_1 C_C_1];
err1=[C1(2)-C_A_1 C1(3)-C_B_1 C1(4)-C_C_1];
N1=norm(err1);
end
I have some experimental values of concentration C given and I have to hypothize the values of of the vector k0 in order to calculate a theoretical concentration. What I would like to do now is to minimize the norm N1 by optimizing the values of k0. I know that there are some functions as fminsearch but I really don't know how to use them. Can someone help me with this? Thank you
回答 (2 件)
Alan Weiss
2016 年 2 月 24 日
0 投票
2 件のコメント
Gisela
2016 年 2 月 24 日
Alan Weiss
2016 年 2 月 24 日
Perhaps this example will help. It uses patternsearch instead of fmincon, but fmincon works, too, especially if you set larger-than-default finite differences.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Star Strider
2016 年 2 月 24 日
0 投票
I cannot follow your code, but if you want to fit data using an ODE in your objective function, see: Monod kinetics and curve fitting.
4 件のコメント
Gisela
2016 年 2 月 25 日
Set
B0 = [k1 a b c]
Time = Vector of the times when the measurements were performed
(threefold repeated) [0 0 0 t1 t1 t1 t2 t2 t2 ... tn tn tn]
Sdata = Vector of concentrations at the time instants for the three components
[C01 C02 C03 C11 C12 C13 C21 C22 C23 ... Cn1 Cn2 Cn3]
x0 = Vector of initial concentrations [C01 C02 C03]
t in the call to ODE45 = [0 t1 t2 ... tn]
S = [Sv(1,1) Sv(1,2) Sv(1,3) Sv(2,1) Sv(2,2) Sv(2,3) ... Sv(n+1,1) Sv(n+1,2) Sv(n+1,3)]
Best wishes
Torsten.
Gisela
2016 年 2 月 25 日
Torsten
2016 年 2 月 25 日
Yes, lsqcurvefit automatically forms the sum of squared differences between S and Sdata.
Best wishes
Torsten.
カテゴリ
ヘルプ センター および File Exchange で Get Started with Optimization Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!