Shooting method for boundary value problems
6 views (last 30 days)
Show older comments
I use ODE45 and the shooting method to solve boundary value problems. There was a specific case in second order differential equations, where an unknown initial condition (which is to be found using shooting method) is a part of the expression of the second derivative, something like the following code. I want to know how to include it in the function and do I need to use any looping statements for it.
funtion dy = diffe(x,y)
l = 2;
p = 3;
dy = [y(2); p*x^2+2*y(1)+y0];
end
So in this code, value of dy/dx at x=0 is known but the value of y at x=0 is not known, but the value of y at x=1 (second boundary is known). This function is to be called like this:
funtion odesolver
dy0 = 0;
[x,y] = ode45(@diffe, [0 1], [y0, dy0]);
end
If someone can recommend a solution to this, that'll be very helpful.
Answers (1)
Basavaraj
on 29 Oct 2024
funtion dy = diffe(x,y)
l = 2;
p = 3;
dy = [y(2); p*x^2+2*y(1)+y0];
end
funtion odesolver
dy0 = 0;
[x,y] = ode45(@diffe, [0 1], [y0, dy0]);
end
0 Comments
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!