Below I attached the code:
P and T are symbolic variables.
The symbolic Function Vector:
AnalyticalConc = [3/8 - (3*exp(P*(1/(2*T) - 1)))/8 ;
exp(P*(1/(2*T) - 1))/32 - (3*exp(2*P*(1/(2*T) - 1)))/8 + 11/32 ;
(11*exp(P*(1/(2*T) - 1)))/384 + exp(2*P*(1/(2*T) - 1))/32 - (3*exp(3*P*(1/(2*T) - 1)))/8 + 121/384 ;
...
]'
(note: I didn't write all the elements! there are three symbolic element more - total six elements).
time = [1 2 3 4 5 6];
The experimental data = [0.039 0.059 0.062 0.072 0.069 0.068]; Now I would like to optimizae the parameters P and T, hence:
x0 = [0.1, 6]; %%[P T] initial values
[solution,resnorm,residual,exitflag] = lsqcurvefit(@fun,x0,time,ExperimentalConc);
function F = fun(x,xdata)
syms P T
load('AnalyticalConc.mat');
time=1:6;
ind=find(time==xdata);
F = double(subs(AnalyticalConc(ind),[P,T],[x(1),x(2)]));
end
In the case that I change the initial values to [0.02 9], for example, the optimal parameters also change!