MatLab will integrate numerically even without numbers

조회 수: 4 (최근 30일)
Jessica Dipold
Jessica Dipold 2020년 6월 15일
댓글: Jessica Dipold 2020년 6월 15일
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
John D'Errico
John D'Errico 2020년 6월 15일
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 2020년 6월 15일
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!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by