help me to fix this error

function trybvp
%EX5BVP Example 5 of the BVP tutorial.
% Falkner-Skan BVPs are discussed in T. Cebeci and H.B. Keller,
% Shooting and parallel shooting methods for solving the Falkner-Skan
% boundary-layer equation, J. Comp. Phy., 7 (1971) 289-300. This is
% the positive wall shear case for which the parameter beta is known
% and the problem is to be solved for a range of the parameter. This
% is the hardest case of the table in the paper.
%
% The problem is posed on [0 infinity). As in the paper cited, the
% boundary condition at infinity is imposed at a finite point, here
% called 'infinity'. It is best to start with a relatively small value
% and increase it until consistent results are obtained. A value of 6
% appears to be satisfactory. Starting with a "large" value is tempting,
% but not a good tactic because the code will fail with the crude guess
% and default tolerances used here.
% 'infinity' is a variable to facilitate experimentation.
infinity = 11;
% The constant guess for the solution satisfies the boundary conditions.
solinit = bvpinit(linspace(0,infinity,10),[0 0 0 0 0 0 0 0 0]);
options = bvpset('stats','on');
sol = bvp4c(@ex5ode,@ex5bc,solinit,options);
eta = sol.x;
f = sol.y;
fprintf('\n');
fprintf('Value computed here is f''(0) = %7.5f.\n',f(4,1))
figure
plot(eta,f(2,:));
axis([0 infinity 0 0.45]);
title('Velocity graph for value n, \n = 0.0.')
xlabel('\eta')
ylabel('df/d\eta')
% --------------------------------------------------------------------------
function dfdeta = ex5ode(~,f)
%EX5ODE ODE function for Example 5 of the BVP tutorial.
n=0.0;
M=0.2;
We=1;
Nb=0.5;
Nr=0.8;
Pr=0.7;
Le=5;
Nt=0.5;
dfdeta = [f(2)
f(3)
f(1)*f(3)+f(2)^2+M*f(2)/((1-n)+n*We*f(3))
f(6)
-Pr*(f(1)*f(6)+Nb*f(9)*f(6)+Nt*f(6)^2)/(1+(4*Nr/3))
f(9)
-(Pr*Le*f(1)*f(9))-(Nt*f(7)/Nb)];
end
% --------------------------------------------------------------------------
function res = ex5bc(f0,finf)
%EX5BC Boundary conditions for Example 5 of the BVP tutorial.
Bi=2;
delta=1;
gamma=-1;
Nb=0.5;
We=1;
n=0.0;
Nt=0.5;
M=0.2;
res = [f0(1)
f0(2)-1-delta*f0(3)+gamma*(f0(1)*f0(3)+(f0(2))^2+M*f0(2))/((1-n)+n*We*f0(3))
f0(6)-Bi*(f0(5)-1)
Nb*f0(9)+Nt*f0(6)
finf(2)
finf(5)
finf(8)];
end
end
Error using bvparguments (line 108)
Error in calling BVP4C(ODEFUN,BCFUN,SOLINIT,OPTIONS):
The derivative function ODEFUN should return a column vector of length 9.
Error in bvp4c (line 129)
[n,npar,nregions,atol,rtol,Nmax,xyVectorized,printstats] = ...
Error in trybvp (line 27)
sol = bvp4c(@ex5ode,@ex5bc,solinit,options);*

回答(1 个)

Jan
Jan 2018-7-15
编辑:Jan 2018-7-15

0 个投票

Your initial value has 9 elements: [0 0 0 0 0 0 0 0 0], but ex5ode and ex5bc reply a [7 x 1] vector only. Of course the derivative need to have as many elements, as the trajectory has.
In ex5ode the element f(9) occurs, so I guess the 9 elements of the initial value are correct. Then fix dfdeta and res.

类别

标签

Community Treasure Hunt

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

Start Hunting!

Translated by