problem while running shooting method program

function shoot2
% Shooting method for 2nd-order boundary value problem
% in Example 8.1.
global XSTART XSTOP H % Make these params. global.
XSTART = 0; XSTOP = 2; % Range of integration.
H = 0.1; % Step size.
freq = 2; % Frequency of printout.
u1 = 1; u2 = 2; % Trial values of unknown
% initial condition u.
x = XSTART;
u = fminbnd(@residual,u1,u2);
[xSol,ySol] = ode23(@dEqs,x,inCond(u),XSTOP,H);
printSol(xSol,ySol,freq)
function F = dEqs(x,y) % First-order differential
F = [y(2), -3*y(1)*y(2)]; % equations.
function y = inCond(u) % Initial conditions (u is
y = [0 u]; % the unknown condition).
function r = residual(u) % Boundary residual.
global XSTART XSTOP H
x = XSTART;
[xSol,ySol] = ode23(@dEqs,x,inCond(u),XSTOP,H);
r = ySol(size(ySol,1),1) - 1;
Errors
Error using odearguments (line 21)
When the first argument to ode23 is a function handle, the tspan argument
must have at least two elements.
Error in ode23 (line 112)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in shoot2>residual (line 21)
[xSol,ySol] = ode23(@dEqs,x,inCond(u),XSTOP,H);
Error in fminbnd (line 215)
x= xf; fx = funfcn(x,varargin{:});
Error in shoot2 (line 11)
u = fminbnd(@residual,u1,u2);

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by