Problem with ordinary differential equation
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Fatemeh
am 22 Apr. 2023
Kommentiert: Fatemeh
am 23 Apr. 2023
Hello, can anyone clarify me why I'm getting a line chart with the following code and how can I fix that? My initial conditions are y(C0)=t0, and y'(C0)=0. Thanks
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= (((1-a)/a)*N^(a+b))/(r-m);
Dy = diff(y);
D2y = diff(y,2);
ode = y-((((1-a)/a)*N^(a+b))-x*m*Dy+0.5*D2y*(x^2)*(s^2))/(r-m);
[VF,Subs] = odeToVectorField(ode);
odefcn = matlabFunction(VF, 'Vars',{x,Y});
tspan = [C0 80];
ic = [t0 0];
[x1,y1] = ode45(odefcn, tspan, ic);
figure
plot(x1,y1(:,1), 'DisplayName','(x_1,y_1_1)')
grid
0 Kommentare
Akzeptierte Antwort
Star Strider
am 22 Apr. 2023
The initial condition of 0 for keeps it 0 througuout the integration.
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= (((1-a)/a)*N^(a+b))/(r-m)
Dy = diff(y);
D2y = diff(y,2);
ode = y-((((1-a)/a)*N^(a+b))-x*m*Dy+0.5*D2y*(x^2)*(s^2))/(r-m);
[VF,Subs] = odeToVectorField(ode)
odefcn = matlabFunction(VF, 'Vars',{x,Y})
tspan = [C0 80];
ic = [t0 0];
[x1,y1] = ode45(odefcn, tspan, ic);
figure
plot(x1,y1(:,1), 'DisplayName','(x_1,y_1_1)')
grid
.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!