Setting the initial value of a differential equation as an unknown parameter and to do optimization
Show older comments
I had a question about doing numerical fitting by ode45 solver and optimization tool. Is there a way to put the initial state as one of the fitting parameter and to find the best value from optimization?
I've tried with a known initial state value, z0, and the code worked well. The fitted line goes through the first data point designed as z0. However, I want to introduce more fitting parameters that the optimized curve might not pass through it.
Here is the original code:
ODE_Sol = ode45(@(t,z)MyodeFcn(t,z,c0), expTime, z0);
simY = deval(ODE_Sol, expTime);
myObjective = @(x) objFcn(x, expTime, expY,tSpan, z0);
bestc = lsqnonlin(myObjective, c0, lb, ub, options);
function dz = MyodeFcn(t, z, c)
dz = zeros(2,1);
dz(1)=-0.0356*z(1)-c(1)*z(1)*exp(-c(2)*t);
dz(2)= -z(2)*c(3)+c(1)*z(1)*exp(-c(2)*t);
I want to replace the known "z0" to [c(4) c(5)].
Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!