MATLAB: Data fitting starting from a coupled system of differential equations

;coupled differential equationlsqcurvefit

I have a coupled system of differential equations, which I defined in the following way:
dx= zeros(2,1);
dx(2)= -K1*x(1)*x(2)./(K3+x(2));
I have some experimental data for x(1) at a given time grid. (I have about 30 values).
I would like to find the values of the parameters K1,K2,K3 such that the solution of the ODE fits these experimental data.
How can i program this in matlab?? I'd like to use a least square minimisation to get my parameters… how can I use the function ''lsqcurvefit'' in the optimisation toolbox starting from a coupled system of differential equations??
thank you very much in advance.

Best Answer

  • You're not going to be able to use a curve-fitting tool to find your parameters, you're solving an optimisation problem. Essentially you're interested in minimising an objective (e.g. sum of squared error) given input K1, K2, and K3. Here's approximately what I'd do as a first cut:
    1. Write a function that for specific K1, K2, K3, solves the ode on your time grid (specify the grid points as the TSPAN option to ode45/23/23s/etc to get the output interpolated to those values) and evaluates your objective (sum of squared deviations at the time points)
    2. Find an approximate K1, K2, K3 by trial and error that give you a somewhat correct answer (by eye). You probably want to be graphing your solutions vs your data here.
    3. Use something like fminsearch to optimise your function from 1., starting at your approximate solution from 2.