How to solve a system of odes where every equation is a function-handle?
2 views (last 30 days)
Show older comments
Well, my title tells all about my question.
I have a system (5x5) of differential equations. I have found these equations. Each equation is a function handle, like you can see bellow:
df1/dt = @(yq)interp1(y1,fy1,yq);
df2/dt = @(yq)interp1(y2,fy2,yq);
df3/dt = @(yq)interp1(y3,fy3,yq);
df4/dt = @(yq)interp1(y4,fy4,yq);
df5/dt = @(yq)interp1(y5,fy5,yq);
How can I solve this system by mean of ode45?
I can not solve them separately, like for example:
tspan = [0 10];
[~, X1approx] = ode45(@(t,y1)f1(y1, tspan, x0);
This is the reason why I am struggling with this one!
I have to send all 5 equations to ode45 at the same time. The reason of this is because the parameters in the function-handle-system are dependent on each other.
I am open for other type of solutions and/or suggestions.
Thanks for your help!!!
0 Comments
Answers (1)
Jan
on 5 Oct 2014
You want to integrate a set of linear interpolations. Linear interpolations are not smooth and the reliability of the result will be questionable, see http://www.mathworks.com/matlabcentral/answers/59582#answer_72047 .
It is not clear what "y1" and "fy1" etc. contain. As long as we cannot see, how the equations are coupled, it is impossible to guess how this can be implemented. The anonymous function for "dx1/dt" has teh input "x1", but does not use it?!
See Also
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!