ODE solver: Undefined function or variable 'y'?

I'm attempting to find the intersection of two ODEs. I use the exact code provided here , but using different ODEs:
syms u(t) v(t)
ode1 = diff(x) == 0.25*x - 0.002*x.^2 - 0.005*x*y;
ode2 = diff(y) == 0.05*y - 0.009*y.^2 - 0.005*x*y;
odes = [ode1; ode2]
S = dsolve(odes)
xSol(t) = S.x
ySol(t) = S.y
[xSol(t), ySol(t)] = dsolve(odes)
cond1 = x(0) == 0.4184;
cond2 = y(0) == 0.6315;
conds = [cond1; cond2];
[xSol(t), ySol(t)] = dsolve(odes,conds)
fplot(xSol)
hold on
fplot(ySol)
grid on
legend('xSol','ySol','Location','best')
I get the following error:
Undefined function or variable 'y'. _ Error in final_2 (line 3) ode1 = diff(x) == 0.25*x - 0.002*x.^2 - 0.005*x*y;
Any help?

 채택된 답변

Star Strider
Star Strider 2017년 5월 15일

0 개 추천

The problem is here:
syms u(t) v(t)
ode1 = diff(x) == 0.25*x - 0.002*x.^2 - 0.005*x*y;
ode2 = diff(y) == 0.05*y - 0.009*y.^2 - 0.005*x*y;
You need to re-define ‘ode1’ and ‘ode2’ in terms of ‘u’ and ‘v’. The Symbolic Math Toolbox requires that the variables be declared first, before you use them in your code.

추가 답변 (0개)

카테고리

태그

질문:

2017년 5월 15일

답변:

2017년 5월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by