
2 dependent ode45 equation
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dhaval Patel
am 9 Okt. 2020
Beantwortet: Bjorn Gustavsson
am 9 Okt. 2020
One ode equation gives the answer in array like 40 x 1, Now this answer becomes input to second ode equation. How can i solve this type of equation?
0 Kommentare
Akzeptierte Antwort
Bjorn Gustavsson
am 9 Okt. 2020
If you have 2 coupled ODEs:

Then it is best to integrate them toghether.
If you for some reason cannot do that or your problem completely prohibits that (you sould explain your problem in some more detail, I'm currently shooting in more or less complete darkness...). You might have to define your second ODE something like this:
function dydt = ODEcomplicated(t,y,t_x,x)
x = interp1(t_x,x,t,'pchip'); % This *migth* be OK
dxdt = interp1(t_x,gradient(x,t_x),t,'pchip'); % This is a really
% dodgy interpolation of
% a numerical estimate of
% the time-derivative of x!
dydt = g(t,y,x,dxdt);
end
Then you'll simply solve the second ODE something like this:
t_span = [0,10];
y0 = 12;
[t,y] = ode45(@(t,y) ODEcomplicated(t,y,t_x,x),t_span,y0);
Where t_x and x are the outputs from the integration of your first ODE. Since you'll have to interpolate the values of x (and possibly its derivatives) between the points in time for which you have the values, this will likely not be the best solution, but might work OK. First approach is much preferred.
HTH
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!