BVP Error, help with explaination
Hello all,
I am struggeling a bit with understanding why I get an error message here. The code works fine with bigger numbers for A or with smaller numbers for B but is crashing for example with the given parameters. I already figured that y(1) is becoming NaN at some point which causes the code to crash. Could somebody help me understand why this is happening?
bvp()
function bvp
A = 50e-3;
B = 1;
xmesh = linspace(0, 1, 100);
sol_init = bvpinit(xmesh, @init);
sol = bvp4c(@ode, @bcfun, sol_init);
function dydx = ode(x, y)
dydx(1) = y(2);
dydx(2) = exp(y(1)*log(10)/A);
%disp(y(1))
end
% Define the boundary conditions
function res = bcfun(ya, yb)
res(1) = ya(1) – B;
res(2) = yb(1);
end
% Define the initial guess for the solution
function guess = init(x)
guess(1) = B;
guess(2) = 0;
end
endHello all,
I am struggeling a bit with understanding why I get an error message here. The code works fine with bigger numbers for A or with smaller numbers for B but is crashing for example with the given parameters. I already figured that y(1) is becoming NaN at some point which causes the code to crash. Could somebody help me understand why this is happening?
bvp()
function bvp
A = 50e-3;
B = 1;
xmesh = linspace(0, 1, 100);
sol_init = bvpinit(xmesh, @init);
sol = bvp4c(@ode, @bcfun, sol_init);
function dydx = ode(x, y)
dydx(1) = y(2);
dydx(2) = exp(y(1)*log(10)/A);
%disp(y(1))
end
% Define the boundary conditions
function res = bcfun(ya, yb)
res(1) = ya(1) – B;
res(2) = yb(1);
end
% Define the initial guess for the solution
function guess = init(x)
guess(1) = B;
guess(2) = 0;
end
end Hello all,
I am struggeling a bit with understanding why I get an error message here. The code works fine with bigger numbers for A or with smaller numbers for B but is crashing for example with the given parameters. I already figured that y(1) is becoming NaN at some point which causes the code to crash. Could somebody help me understand why this is happening?
bvp()
function bvp
A = 50e-3;
B = 1;
xmesh = linspace(0, 1, 100);
sol_init = bvpinit(xmesh, @init);
sol = bvp4c(@ode, @bcfun, sol_init);
function dydx = ode(x, y)
dydx(1) = y(2);
dydx(2) = exp(y(1)*log(10)/A);
%disp(y(1))
end
% Define the boundary conditions
function res = bcfun(ya, yb)
res(1) = ya(1) – B;
res(2) = yb(1);
end
% Define the initial guess for the solution
function guess = init(x)
guess(1) = B;
guess(2) = 0;
end
end bvp, ode, ode45, differential equations MATLAB Answers — New Questions