unknown parameters differential equation
4 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Amit
2014-12-9
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!