Coupled set of odes
Afficher commentaires plus anciens
Hi, I want to solve these coupled set of odes. dy/dt =f1(y)+c1*x; dx/dt =f2(x)+c2*y; Where both x and y are vectors of different size. How to do it using ode45?
Réponses (1)
Alan Stevens
le 31 Oct 2020
The structure could look something like this
tspan = [0 tfinal];
IC = [x0 y0];
[t, xy] = ode45(@fn, tspan, IC);
x = xy(:,1);
y = xy(:,2);
function dxydt = fn(t,IC)
c1 = ...;
c2 = ...;
x = IC(1);
y = IC(2);
f1 = ... (using y);
f2 = ... (using x);
dxydt = [f2 + c2*y;
f1 + c1*x];
end
where you would have to fill in with your values of c1, c2 etc.
8 commentaires
Sib RV
le 31 Oct 2020
Sib RV
le 31 Oct 2020
Alan Stevens
le 31 Oct 2020
I took your expressions to mean f1 and f2 were functions (of y and x respectively).
When you say x and y are of different lengths, are you referring to values that represent initial conditions?
Alan Stevens
le 31 Oct 2020
Modifié(e) : Alan Stevens
le 31 Oct 2020
So what do the functions look like (i.e. their mathematical form); what is the time interval of integration and what are the values of x(t=0) and y(t=0)? And what are the values of c1 and c2?
Alan Stevens
le 31 Oct 2020
If f1 and f2 are aso constants then it becomes even easier. Where I had
f1 = ... (using y);
f2 = ... (using x);
you simply put
f1 = ... ;
f2 = ... ;
i.e. you specify their values.
Then as long as you have intial values for x and y to go into IC you can integrate up to a time of your choosing.
I don't understand what you mean by having different numbers of x and y values. Do you mean you have values you want to compare the output against?
Do you know the values of f1, f2, c1 and c2, or are you trying to fit them by using x and y data values that you have?
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!