Error using bvp4c
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
I'm trying to run the following code but keep running into an error ( singular Jacobian encountered). I added a picture of what I am trying to solve. Could someone help me with the code or suggest a different method how to solve the equations numerically?

I chose a and mu to be -0.8 and -0.2 respectively because I know the system should have solutions for these values. For the initial guess I tried constants and some kind of exponential functions but it never worked.
function GPE1
rmax=100;
dr=0.01;
options = bvpset('stats','off','RelTol',1e-6);
solinit = bvpinit(linspace(0,rmax,rmax/dr),@guess);
sol = bvp4c (@OdeBVP, @OdeBC, solinit, options);
plot(sol.x,sol.y(1,:))
function f=OdeBVP(x,y)
f=[
y(2);
(-2/x)*y(2)*y(1)+8*pi*(-0.8)*abs(y(1))^2*y(1)+y(3)*y(1)-0.2*y(1);
y(4);
8*pi*abs(y(1))^2-(2/x)*y(4);
];
function res= OdeBC(ya,yb)
res= [yb(1);
ya(2);
ya(4);
yb(3)+(2/100);
];
function yinit= guess(x)
yinit= [exp(-0.5*x.^2);
x*exp(-0.5*x.^2);
exp(-0.5*x.^2);
x*exp(-0.5*x.^2);
];
Antworten (0)
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!