MatLab will integrate numerically even without numbers

6 vues (au cours des 30 derniers jours)
Jessica Dipold
Jessica Dipold le 15 Juin 2020
Commenté : Jessica Dipold le 15 Juin 2020
Hello,
I am running a code to solve a system of ODES. In my main code, I make a loop around the y value, and then attempt to solve this equation system with ode23tb (I also tried ode15, but the wrong result is the same):
function Deriv = EDOFun (t,x)
global x0 p W0 y
global A c beta cs T
syms z
Deriv = zeros(2,1);
f=sqrt(2/pi/T^2)*exp(-2*(t-2*T).^2/T^2);
W = W0*(f);
sol = int(x(1)*x(2)*z*exp(-z/x0),z,0,Inf);
Deriv(1) = beta*A*x(2) + c*cs*x(2)*x(1) - (c/y)*x(1);
Deriv(2) = W - A*x(2) - c*cs*(p*x(2)*x(1)) + ((1-p)/x0^2)*sol);
The problem here is that both x(1) and x(2) should be dependent of the z in the integral. If I choose to name x instead of z for it, however, the program will not work. And if I use it this way, MatLab will simply calculate the integral disregarding the fact that x(1) and x(2) should be a solution of this system of equations.
Is there a way MatLab can actually do this calculation, or should I go back to the math in my problem to be able to fix it?
  2 commentaires
John D'Errico
John D'Errico le 15 Juin 2020
You cannot use a numerical solver, thus ODE23tb, to solve a problem with symbolic variables in it. I suppose you have eliminated z in the integral though. But I would at the very least do some basic mathematics. For example,
sol = int(x(1)*x(2)*z*exp(-z/x0),z,0,Inf);
is nothing more than
x(1)*x(2)*x0^2
as long as x0 is real and non-zero.
What you don't show is how x(1) and x(2) are dependent on z.
Jessica Dipold
Jessica Dipold le 15 Juin 2020
I did eliminate z in the integral, or I thought I did at least.
Well, x(1) and x(2) are actually the solutions of the ODE, so I do not know how they are dependent of z, which is actually x originally. The original equation system is this one
I will try your suggested math solution first anyways to see how it shifts my answer curves. Thank you for your fast response too!

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by