You are on page 1of 2

4/18/2016

TwoPointBoundaryValueProblemsNumericalMethodsinEngineeringwithMATLABpage307

GraphicsProgramsReference
InDepthInformation

< 0andy(0)
> 0.Basedonthisratherscantyinformation,
Ifweareright,theny(0)
= 1andy(0)
= 1.
wetryy(0)
ThefollowingprogramusestheadaptiveRungeKuttamethod(runKut5)for
integration:

functionshoot4nl
%Shootingmethodfornonlinear4thorderboundary
%valueprobleminExample8.5.

globalXSTARTXSTOPH

%Maketheseparams.global.

XSTART=0XSTOP=1

%Rangeofintegration.

H=0.1

%Stepsize.

freq=1

%Frequencyofprintout.

u=[11]

%Trialvaluesofu(1)
%andu(2).

x=XSTART
u=newtonRaphson2(@residual,u)
[xSol,ySol]=runKut5(@dEqs,x,inCond(u),XSTOP,H)
printSol(xSol,ySol,freq)

functionF=dEqs(x,y)

%Differentialequations.

F=zeros(1,4)
F(1)=y(2)F(2)=y(3)F(3)=y(4)
ifx<10.0e4F(4)=12*y(2)*y(1)2
else

F(4)=4*(y(1)3)/x

end

functiony=inCond(u)

%Initialconditionsu(1)

y=[00u(1)u(2)]

%andu(2)areunknowns.

functionr=residual(u)%Boundayresiduals.
globalXSTARTXSTOPH
r=zeros(length(u),1)
x=XSTART
http://whatwhenhow.com/Tutorial/topic4142fqs/NumericalMethodsinEngineeringwithMATLAB316.html

1/2

4/18/2016

TwoPointBoundaryValueProblemsNumericalMethodsinEngineeringwithMATLABpage307

x=XSTART
[xSol,ySol]=runKut5(@dEqs,x,inCond(u),XSTOP,H)
lastRow=size(ySol,1)
r(1)=ySol(lastRow,3)
r(2)=ySol(lastRow,4)1

PreviousPage

NextPage

NumericalMethodsinEngineeringwithMATLAB

SearchWWH::
Search

Custom
Search

Home

http://whatwhenhow.com/Tutorial/topic4142fqs/NumericalMethodsinEngineeringwithMATLAB316.html

2/2

You might also like