In the definition of bvp_function, when MATLAB reaches the line
dYdx(2) = (Y(2) + Y(4)) * (num1 - Y(2) - dYdx(3)/Y(3) - dYdx(4));
at that time, the values of dYdx(3) and dYdx(4) are undefined, so MATLAB throws an error.
You can solve this problem, either by changing the order of calculation like this
function dYdx = bvp_function(x, Y)
num1 = 2.331;
dYdx(4) = -Y(2)*exp(Y(1));
dYdx(3) = Y(2) + dYdx(4) - Y(3);
dYdx(1) = Y(2);
dYdx(2) = (Y(2) + Y(4)) * (num1 - Y(2) - dYdx(3)/Y(3) + dYdx(4));
dYdx = dYdx(:);
end
or replace the values of c' and t' in equation 1 and 2 like this
function dYdx = bvp_function(x, Y)
num1 = 2.331;
dYdx(1) = Y(2);
dYdx(2) = (Y(2) + Y(4)) * (num1 - Y(2) - (Y(2) - Y(2)*exp(Y(1)) - Y(3))/Y(3) + Y(2)*exp(Y(1)));
dYdx(3) = Y(2) - Y(2)*exp(Y(1)) - Y(3);
dYdx(4) = -Y(2)*exp(Y(1));
dYdx = dYdx(:);
end
However, even after this, there seems to be a singularity in your system of ODEs. You need to analyze your equations to see what might be causing the singularity.
Best Answer