Ho do I use Interp1 together with ODE45?
1 view (last 30 days)
Show older comments
I am using the ode45 solver in the function:
-------------------------------------------------------------------
function Mdot_s = HKode(t, ms_HK, T_bulk, k_so, k_sf, m_fuel)
m_fuel=interp1(T_bulk,m_fuel,t);
k_sf=interp1(T_bulk,k_sf,t);
k_so=interp1(T_bulk,k_so,t);
Mdot_s = (m_fuel.*k_sf)-(k_so.*(ms_HK));
---------------------------------------------------------------------
to solve for the time-dependent variable "ms_HK."
In the main code, "T_bulk" is a time-dependent vector with a few hundred values, and "m_fuel," "k_sf," and "k_so" (for brevity, lets refer to these collectively as "var") are calculated (in the main code)from "T_bulk," so they are vectors of equal length to that of "T_bulk."
----------------!!!The Problem !!!------------------
the interp1 values calculated for "var" are outside of the known vector values for "var."
-----------------------------------------------------
My understanding of the interp1 function was that it would interpolate between known values of "var" and "T_bulk" using steps of "t" defined by the ode45 solver to give a more refined vector of "var" values for use in ode45. Am I misunderstanding how interp1 is supposed to be used with ode45?
I call the function in the main code using:
[t, ms_HK] = ode45(@(t,ms_HK) HKode(t,ms_HK,T_bulk,k_so, k_sf, m_fuel),Tspan,IC_HK, options); % Solve ODE
0 Comments
Answers (0)
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!