Problem with solving an ODE
3 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Torsten
on 17 May 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 Comments
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!