Hey guys I am in desperate need of help. I am struggling in finding code for the shooting method for second order BVP. I use Eulers method for IVP but the problem is I am still unsure of how it would look in code. Would it maybe be better to use ODE45-Runga-kutta instead? I have had a try but to no success. The problem is (I think) is that my inputs don't talk to each other and that some steps are missing. Can someone please give me the code to solve:(adsbygoogle = window.adsbygoogle || []).push({});

y′′ = y + 2/3*e^t, y(0) = 0, y(1) = 1/3*e

Or point out where I made my mistake in my code. I am honestly lost atm:

%attempt at shooting sol using Euler for

% (d/dx)(dT/dx)=2, y(0)=1, y(1)=0

% If Value=T and Slope=dT/dx systesm is

% dValue/dx=Slope, Value(0)=1;

% dSlope/dx=0;, Slope(0)=Unknown--we need to guess

function solve()

x=0; %initial point

y0=1; %initial value at x=0

y'=-1; %initial Guess for slope

Vknown=0; %Known Value at x =1

del=0.1; %solution step size

Diff=10; %difference between predicetd abnd knonw value ay x =1

inter=[x,Vknown];

while abs(Diff)>0.001

euler(inter,yo,n);...

Slope=Slopei;

Value=Valuei;

for i=1:10

Value=Value+del*Slope;

Slope=Slope+del*2; %very simple in this case

end

Diff=Value-Vknown; %Difference between predicetd and known Value

% Update Slope(0) guess

Slopei=Slopei-1*Diff

end

end

function [t,y]=euler(inter,yo,n)

t(1)=inter(1);y(1)=y0;

h=(inter(2)-inter(1))/n;

for i=1:n

t(i+1)=t(i)+h;

y(i+1)=eulerstep(t(i),y(i),h);

end

plot(t,y)

end

function eulerstep(t,y,h)

y=y+h*ydot(t,y);

end

function z=ydot(t,y)

z=t*y+t^3

end

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Shooting Method Matlab Code

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads - Shooting Method Matlab | Date |
---|---|

C/++/# Typically where are preconditions checked for methods? | Jan 22, 2018 |

What's wrong with my bisection method code? | Dec 10, 2017 |

"Shooting Method" for simulating a Particle in an Infinite Square Well | Mar 10, 2017 |

Boundary conditions shooting method | Nov 29, 2015 |

Shooting method and a shock wave (discontinuity at the inner boundary condition) | Jul 7, 2008 |

**Physics Forums - The Fusion of Science and Community**