How to solve a system of odes where every equation is a function-handle?

2 views (last 30 days)
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!!!

Answers (1)

Jan
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?!
  1 Comment
Sergio
Sergio on 6 Oct 2014
Hi Jan Simon. Thanks for your answer. I can see how vague and diffuse my question is, sorry for that! The problem is that I don't really know how to formulate my question without talking about unnecessary things.
I'll try again, please FORGET my first question .
I am working with experimental mathematics. The core of my work is that I can take a simple time-serie, let us say for example from a (2x2) system of odes. Let's call this (2x2) originally system ModelA. From the time-series of ModelA I can construct a new system , let us called it ModelB, which is a (2x2) system of odes as well . The interesting part is that Model2 captures all the non-linearities of ModelA, which means that ModelB is able to reconstruct the dynamic ModelA just from time series data.
The hole is based on SVD from linear algebra and PCA from statistics.
Anyways, I have in my Editor-windown in matlab a long code and at the end I have everything I need to construct two functions: funct_one and funct_two; this is ModelB :).
To form the first function I have two column vectors, the first vector (called fy1) contain function-values and the second one (called y1) contain the points where the function values where computed. So it would be easy to just interpolate this two vectors and get a function which I can send to ode45. Interpolation is not a MUST, I just did't know/found any other way to making a function from these two vectors... I have something like:
% I defines a time-interval first
% and the initial condition
fun_one = @(yq) interp1(y1,fy1,yq)
[~,funct_one] = ode45(@(t,y1) funct_one(y1), time_interval, initial_condition)
And I could do the same to get the second function and solved it by means of ode45. But this is wrong, because I need to send both functions to ode45 since they form a system of odes! and it is here I am struggling very much! How can:
1.- Create or make these functions that I need, and send them to ode45 to solve the system?
2.- ...and I need to send the hole system to ode45, not one equation at the time.
I hope this was more clear!
cheers!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!