How to fix ode graphs?
古いコメントを表示
Hello, I'm trying to combine these two ode plots into one chart, but it gives me two different charts. Can someone please help me with this?
syms y(x) x Y
N=5;
r=0.05;
m=0.01;
p=1;
s=1;
t=0.1;
a=0.25;
b=0.25;
C0=1;
C=5;
t0= N+r+t*p*s-m;
t1=-(N+r+t*p*s-m);
Dy = diff(y);
D2y = diff(y,2);
ode = y-(1/x)*(N+r)-((t*p*s*Dy)/y)+((Dy*((s^2)-m))/y)+((D2y*x*(s^2))/(2*y));
[VF,Subs] = odeToVectorField(ode);
odefcn = matlabFunction(VF, 'Vars',{x,Y});
tspan = [C0 80];
ic = [t0 t1];
[x,y] = ode45(odefcn, tspan, ic);
figure
plot(x, y)
grid
hold on
syms y(x) x Y
f=(x+(x^2+4*r*x*(1-a-b))^0.5)/(2*(1-a-b));
t00=N/C;
t11=-N/(C^2);
Dy = diff(y);
D2y = diff(y,2);
ode2= y-((C-x+f*((1/(r+f))^(1/(1-a-b)))+t*p*s*x*Dy+x*Dy*((s^2)-m)+Dy*(C-x)+0.5*D2y*(x^2)*(s^2)-x*(s^2)*Dy)/x*(1+t*p*s-m));
[VF1,Subs1] = odeToVectorField(ode2);
odefcn1 = matlabFunction(VF1, 'Vars',{x,Y});
tspan2 = [C 1];
ic2 = [t00 t11];
[x,y] = ode45(odefcn1, tspan2, ic2);
figure
plot(x, y)
grid
hold off
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



