Unable to solve the collocation equations -- a singular Jacobian encountered.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Della
le 8 Juin 2023
Réponse apportée : Star Strider
le 8 Juin 2023
Hi, I'm trying to run the code below. However, it displays the following error message: "Unable to solve the collocation equations -- a singular Jacobian encountered". Is there any way to solve this problem? Thanks in advance.
syms y(x) x Y
k=5/8;
w=100;
q=1;
p1=1;
r=0.06;
e=0.5;
a=1/3;
t=0.9;
s1=2;
m2=0.5;
sigma=(1-k)*(e/(1-e));
Dy=diff(y,1);
D2y=diff(y,2);
t0y=(1-a)/(e^2+a*e-a*(e^2)-2*e+1)/(r+t*p1*s1-sigma*m2-0.5*sigma*(sigma-1)*(s1^2));
ezafe=(1/(1+((1-a)/(e^2-a*e-a*(e^2)-2*e+a))))*(1/(((1-a)/(e^2-a*e-a*(e^2)-2*e+a)-Dy*x))*((1-e)*(e^2-a*e-a*(e^2)-2*e+a)/(1-e*(1-a)*(e/(1-e))*((1-a)/w*q*a)^(e/(1-e)))))^((1-a)*(1-e)/(1-e*(1-a)));
gq=((x*(r-sigma*m2-0.5*sigma*(sigma-1)*(s1^2)+(sigma^2)*(s1^2)-ezafe)));
ode=y-(((1-a)/(e^2+a*e-a*(e^2)-2*e+1))+t*p1*Dy*sigma*x*s1+0.5*D2y*(x^2)*(sigma^2)*(s1^2)-Dy*x*(sigma^2)*(s1^2)+Dy*gq)/(r+t*p1*sigma*s1-sigma*m2-0.5*sigma*(sigma-1)*(s1^2));
[VF,Subs] = odeToVectorField(ode);
odefcn = matlabFunction(VF, 'Vars',{x,Y});
bcfcn = @(ya,yb)[ya(1)-t0y;yb(1)];
xmesh = linspace(0.001,450,10);
solinit = bvpinit(xmesh, [1 1]);
sol = bvp4c(odefcn,bcfcn,solinit);
0 commentaires
Réponse acceptée
Star Strider
le 8 Juin 2023
Your ‘odefcn’ has a divide-by-zero somewhere, since at x=0, ‘Y(2)’ is NaN, and setting ‘x’ to something greater than 0 ‘Y(2)’ is Inf, even with ‘Y’ initially set to [1 1].
.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!