I am getting this error for the written code

function bvp4
tic
n=1.5;
s=[0,0,-0,0;0,0,0,-1;0,0,-1,0;0,0,0,-1/n];
options=bvpset('singularterm',s,'RelTol',0.01,'Nmax',50000);
guess=[1;0;0;0];
solinit=bvpinit(linspace(0,1,50),guess,options);
sol = bvp4c(@twoode,@twobc,solinit);
z=linspace(0,1,50);
solint=deval(sol,z);
toc
plot(z,solint(1,:))
function dydx=twoode(x,y)
K=10;
v=0.1;
n=1.5;
zeta=0.3;
dydx=[y(2);y(4);K^2*sinh(y(1))/(1+4*v*(sinh(y(1)/2))^2);-((K^(n+1))*(y(4)^(1-n))*sinh(y(1))/(1+4*v*(sinh(y(1)/2))^2))/(n^(n+1)*zeta)];
function res= twobc(ya,yb)
res=[ya(3);ya(4);yb(1)-0.3;yb(2)];
* _Cell contents reference from a non-cell array object.
Error in bvparguments (line 105)
testODE = ode(x1,y1,odeExtras{:});
Error in bvp4c (line 129)
[n,npar,nregions,atol,rtol,Nmax,xyVectorized,printstats] = ...
Error in new5vel (line 8)
sol = bvp4c(@twoode,@twobc,solinit);_
*

回答(1 个)

Jan
Jan 2018-6-4
编辑:Jan 2018-6-4
Why do you provide the options to bvpinit? If I change this to:
solinit=bvpinit(linspace(0,1,50),guess);
sol = bvp4c(@twoode,@twobc,solinit,options);
( options moved to bvp4c), I get the error:
Unable to solve collocation equations - a singular Jacobian encountered.

2 个评论

Of course it does not help. As I wrote: the equation cannot be solved. But this implies that the readers of the forum cannot help you based on the currently provided information. I assume it is a programming error in the equation, but there is no chance to guess, what the problem is.

请先登录,再进行评论。

类别

产品

评论:

Jan
2018-6-4

Community Treasure Hunt

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

Start Hunting!

Translated by