Call a function from within a set of odes
Show older comments
Hi, I am wondering if there is a way to use functions within a set of odes. I have a set of odes for pressure, temperature, and some other variables within the atmosphere. Within the set of odes, there are a lot of variables which I am representing with experimental correlations, e.g. heat of fusion as a function of temperature with five or six parameters. What I would like to do is write these experimental correlations as separation functions, e.g. function Lw = heatofVap(T) ..., then call these functions from within the odes, e.g. dy(5) = a*y(4) + b*y(3)*y(4) + @heatofVap(y(1))*y(3), so that it is more readable. Is this possible? Could someone give me a syntax example?
Accepted Answer
More Answers (1)
Steven Lord
on 4 Sep 2015
0 votes
Example 3 on the documentation page for ODE45 is somewhat similar to what you're trying to do. It uses INTERP1 to interpolate some sample data needed to compute the right-hand side of the ODE. In your case, instead of calling INTERP1 you'd be calling heatofVap.
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!