Problem with ordinary differential equation
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Fatemeh
el 22 de Abr. de 2023
Comentada: Fatemeh
el 23 de Abr. de 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 comentarios
Respuesta aceptada
Star Strider
el 22 de Abr. de 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
.
Más respuestas (0)
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!