MATLAB: Unknown parameters differential equation

differential equationsdsolvefirringfitting parameterssystem of equationsunknown coefficients

Dear all, I have been struggling with a fairly simple problem but I was hoping for your suggestions. I am trying to solve a set of 2 d.e. with 4 unknown coefficients. I have experimental data and their corresponding time that I would like to fit it to.
A simple case: u'=c1* v – c2 v'=c3* u
[u; v]= [0; 1] at t=0 [u; v]= [-20.0404; -11.5703] at t=1/3*pi
How do I get the values for c1, c2, c3 now? (I am using dsolve to find the solution, but not sure how to compare this with the values at t=1/3*pi)
Thank you for your ideas

Best Answer

The issue here is that you have 3 parameters and 2 equations, so there might not exist an unique solution. However if there exist an unique solution, you can do something like this - Create two function separately (an example below)
function 1: Differential equation
function dy = RKx(t,y,c)
dy = zeros(2,1);
% u'=c1* v - c2 v'=c3* u
% y = [u;v]
dy(1) = c(1)*y(2) - c(2);
dy(2) = c(3)*y(1);
Function 2: This will be optimized
function yval = optimX(C)
yAtTf = [-20.0404 -11.5703];
tspan = [0 pi()/6 pi()/3];
y0 = [0;0];
[~,Y] = ode45(@(t,y) RKx(t,y,C),tspan,y0);
yval = norm(Y(3,:) - yAtTf,2);
In ths end, you minimize the objective optimX using functions like fminunc or fmincon etc (an example below) -
[y,fval] = fminunc(@optimX,rand(3,1))
Hope this will get you to a point where you can figure it out.