MatLab will integrate numerically even without numbers
조회 수: 4 (최근 30일)
이전 댓글 표시
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
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.
답변 (0개)
참고 항목
카테고리
Help Center 및 File 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!
