Problem with solving an ODE
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Della
el 17 de Mayo de 2023
Respondida: Torsten
el 17 de Mayo de 2023
Hello,
When I run the code below, I get an error because the initial condition for y is dependent on Dy. I've seen this case (boundary conditions depend on first derivatives) in a few papers, but I'm not sure how to solve it. Could someone please help me with this?
syms y Dy D2y x Y
y0=(5+Dy*2)/0.49;
ode = y-(1/(Dy/y+(D2y*x)/y))^2;
ode1 = solve(ode==0,D2y)
ode2 = matlabFunction(ode1(1),'Vars',{x,[y Dy]})
odefcn = @(x,y)[y(2);ode2(x,[y(1),y(2)])];
bcfcn = @(ya,yb)[ya(1)-y0;yb(2)-1];
xmesh = linspace(1e-3,4,10);
solinit = bvpinit(xmesh, [1 1]);
sol = bvp4c(odefcn,bcfcn,solinit);
plot(sol.x,sol.x.*sol.y(1,:))
0 comentarios
Respuesta aceptada
Torsten
el 17 de Mayo de 2023
Use
bcfcn = @(ya,yb)[ya(1)-(5+ya(2)*2)/0.49;yb(2)-1];
instead of
bcfcn = @(ya,yb)[ya(1)-y0;yb(2)-1];
in your code.
0 comentarios
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!