Can ode45 handle vector of undetermined coefficients

Hi
I have a system of ODEs and I want to optimise its coefficients with fminsearch. However, "Not enough input argument" is shown when I used ODE45. I have optimised another single ODE's coefficient in the past and it succeed. So I would like to know can ODE45 handle more than one undetermined coefficients? Thank you!

Answers (3)

The call to ODE45 must read
[T,X] = ode45(@(t,x)Est_Opt_VanillininVitro(t,x,k), time, [0.001 0 0 0.1 0.1]);
and the call
[T,Y]= ode45(@Opt_VanillininVitro , time, [0.001 0 0 0.1 0.1]);
can be deleted.
Then you must determine f (usually by building the sum of squared differences between Y and measurement data taken at the times specified in the "time" vector).
Best wishes
Torsten.

1 Comment

Thank you very much Torsten
However [T,X] cannot be computed due to "not enough input arguments". I wasn't too clear about the objective. The main goal is fitting X to Y? Such that the k coefficients in dxdt are similar to dydt.

Sign in to comment.

Torsten
Torsten on 6 Apr 2016
Edited: Torsten on 6 Apr 2016
Since fminsearch suggests coefficients each time before ODE45 is called, there are no undetermined coefficients within ODE45.
We will have to see your code to find your programming error.
Best wishes
Torsten.

1 Comment

I believe the problem starts from ode45 before fminsearch, I wrote the code in several page
First defining the ODEs
function dxdt = Est_Opt_VanillininVitro(t,x,k);
dxdt = zeros(5,1);
dxdt(1) = -x(1) * (k(1) * x(4))./(k(2) + x(1));
dxdt(2) = x(1) * (k(1) * x(4))./(k(2) + x(1)) - (k(3) * x(2)*x(5))./(k(4) + x(2));
dxdt(3) = (k(3) * x(2)*x(5))./(k(4) + x(2));
dxdt(4) = 0;
dxdt(5) = 0;
Then I have the objective function
function f = Opt_Obj_VanillininVitro(k);
time = linspace(0, 0.03);
[T,X] = ode45(@Est_Opt_VanillininVitro, time, [0.001 0 0 0.1 0.1]);
[T,Y]= ode45(@Opt_VanillininVitro , time, [0.001 0 0 0.1 0.1]);
[T,Y] is solved with defined k values in the same ODEs
Finally optimise k values with fminsearch,
k = fminsearch('Opt_Obj_VanillininVitro',[0 0 0 0])
disp(['fminsearch: k = ' num2str(k)]);
I also believe there's a much better way to do this, any suggestion? ^^

Sign in to comment.

Try
[T,X] = ode45(@(t,x)Est_Opt_VanillininVitro(t,x,k), time, [0.001; 0; 0; 0.1; 0.1]);
Best wishes
Torsten.

1 Comment

Okay, I tried and it is still the same. I think is because k values are still unknown in X. However, if I just run the fminsearch, it shows "subscripted assignment dimension mismatch."
I'm very appreciated for your help.
Best King

Sign in to comment.

Asked:

on 6 Apr 2016

Commented:

on 6 Apr 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!