|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
我编了一个程序,如下:
function ex1bvp
%The problem is
%
% v'' = a*v-v*w
% w'' = (1/b^2)*(w-0.5*v^2)
%
% The interval is [0 1] and the boundary conditions are
%
% w(-10) = v(-10) = 0, w(10) = v(10) = 0,
solinit = bvpinit(linspace(-10,10,20),@ex1init);
options = bvpset('Stats','on','RelTol',1e-5);
sol = bvp4c(@ex1ode,@ex1bc,solinit,options);
% The solution at the mesh points
x = sol.x;
y = sol.y;
clf reset
plot(x,y(1,:))
axis auto
xlabel('x')
shg
% --------------------------------------------------------------------------
function dydx = ex1ode(x,y)
% The components of y correspond to the original variables
% as y(1) = v, y(2) = v', y(3) = w, y(4) = w'.
a=1;
b=1;
dydx = [ y(2)
a*y(1)-y(3)*y(1)
y(4)
1/b^2*(y(3)-0.5*y(1)^2) ];
%-------------------------------------------------------------------------
function res = ex1bc(ya,yb)
res = [ ya(1)
ya(2)
yb(1)
yb(2)];
%-------------------------------------------------------------------------
function v = ex1init(x)
%EX1INIT guess for problem of the BVP4C.
a=1;
v = [2*sqrt(a)*sech(sqrt(a)*x)
2*sqrt(a)*sech(sqrt(a)*x)*tanh(sqrt(a)*x)
2*a*(sech(sqrt(a)*x))^2
-4*a*(sech(sqrt(a)*x))^2*tanh(sqrt(a)*x)];
运行后,提示如下出错:
??? Error using ==> bvp4c
Unable to solve the collocation equations -- a singular Jacobian encountered
Error in ==> E:\doctor\matlab\BVP_tutorial\BVP_tutorial\BVP_examples\szw1.m
On line 14 ==> sol = bvp4c(@ex1ode,@ex1bc,solinit,options);
麻烦各位帮忙看一下。
[ 本帖最后由 eight 于 2008-3-10 16:32 编辑 ] |
|