Graphics Programs Reference
In-Depth Information
,
=
y
.Both
F
F = dEqs(x,y)
specifies the first-orderdifferentialequations
F
(
x
y
)
and
y
are column vectors.
r = residual(ya,yb)
specifies all the applicable the boundary residuals
y
i
(
a
)
−
α
i
and
y
i
(
b
)
−
β
i
ina column vector
r
, where
α
i
and
β
i
are the prescribedbound-
ary values.
The thirdinput argument
solinit
is a structurethatcontains the
x
and
y
-values at
the nodes of the initialmesh. Thisstructurecanbe generatedwith MATLAB'sfunction
bvpinit
:
solinit = bvpinit(xinit,@yguess)
where
xinit
is avector containing the
x
-
coordinates of the nodes;
yguess(x)
is auser-supplied function that returns a
column vector containing the trial solutionsfor the components of
y
.
The numerical solutionat user-definedmesh points can beextracted from the
structure
sol
with the MATLAB function
deval
:
y = deval(sol,xmesh)
where
xmesh
is an array containing the
x
-coordinates of
the mesh points. The functionreturns amatrix with the
i
th row containing the
values of
y
i
at the mesh points.
The following program illustrates the use of the abovefunctions in solving
Example 8.1:
function shoot2
matlab
% Solution of Example 8.1 with MATLAB's function bvp4c.
_
xinit = linspace(0,2,11)';
solinit = bvpinit(xinit,@yguess);
sol = bvp4c(@dEqs,@residual,solinit);
y = deval(sol,xinit)';
printSol(xinit,y,1)
% This is our own func.
functionF=dEqs(x,y)
%Differentialeqs.
F = [y(2); -3*y(1)*y(2)];
functionr=residual(ya,yb)%Boundaryresiduals.
r = [ya(1); yb(1) - 1];
function yinit = yguess(x)
% Initial guessses for
yinit = [0.5*x; 0.5];
% y1 and y2.
Search WWH ::
Custom Search