Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: how to connect data to system of differential equations?
Replies: 1   Last Post: Aug 30, 2013 6:32 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Torsten Hennig

Posts: 2,419
Registered: 12/6/04
Re: how to connect data to system of differential equations?
Posted: Aug 30, 2013 6:32 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

> Hi all,
> I have a system of differential equations and a
> construction of different mfiles, which are connected
> to each other. Now I will get a data set constiting
> of values along a 1 year period or more, so the
> structure is:
> time = [1 2 3 4 5 6 7 8 9 10 11 12];
> datavalues = [0.2 0.3 0.5 0.9 1 1.5 1.6 2 0.7 0.6 0.3
> 0.1];
> These datavalues should influence many of the
> differential equations (such as temperature), so
> 'datavalues' is used as a variable in some equations.
> Some other data than temperature will be rather
> random and it would be hard or impossible to come up
> with a formula describing the dataset. Is there a way
> to do this without using Simulink?
> I´d be very happy for a reply :-)


You can pass the data to the function routine where you define your differential equations (here: myode) as

[T Y] = ode45(@(t,y) myode(t,y,time,datavalues),Tspan,IC);

The function myode then should look like

function dy = myode(t,y,time,datavalues)
...

In the function "myode" itself, it will be necessary to interpolate your data to the time t supplied by the solver.
This can be done according to
y_interpolated = interp1(time,datavalues,t)
The value y_interpolated now gives an approximation to the value of your array "datavalues" at time t.
Be careful with the units - t and time must have the same physical unit (e.g. seconds, minutes,...).

Good luck.

Best wishes
Torsten.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.