Hi there, I am trying to use MatLabs bcp4c solver to solve the system:
eq 1: j'' = ( j' + t ) * (num1 – j + c'/c – t')
eq 2: c' = j' + t' – c
eq 3: t' = – j' * exp ( j)
with boundary conditions: j=1, c=0 at x=0 and j=0, c=1 at x=1.
I have linearized the problem, so that: Y(1) = j, Y(2)=j', Y(3) = c, Y(4) = t.
% Define space from 0 to 1.
x = linspace(0, 1, 1000);% Inital guesses for the solver
guess = bvpinit(x, [1;0;1;1]);% Solve function in space:
sol = bvp4c(@(x,Y) bvp_function(x,Y), @(Ya,Yb) boundary_conditons_fcn(Ya,Yb), guess);% Export function:
solution_BVP_num=sol.y;% Boundary conditions:
function res = boundary_conditons_fcn(Ya,Yb)% j=1, c=0 at x=0 and j=0, c=1 at x=1.
res = [Ya(1)-1; Yb(1)-0 Ya(3)-0 Yb(3)-1]; endfunction dYdx = bvp_function(x,Y)% Y(1)=j, Y(2)=j', Y(3) = xsi, Y(4) = t
num1 = 2.331; dYdx(1) = Y(2); dYdx(2) = (Y(2) + Y(4)) * (num1 - Y(2) - dYdx(3)/Y(3) - dYdx(4)); dYdx(3) = Y(2) + dYdx(4) - Y(3); dYdx(4) = -Y(2)*exp(Y(1)); dYdx = dYdx(:);end
I get the error:
"Index exceeds matrix dimensions."
I think I have posed the question in a bad manner. Anybody knows how to solve this?
Hope so. 🙂
Best Answer