MATLAB: I’m trying to solve a fourth order ordinary differential equation using the bvp4c function. However, I am getting a few errors in the code.

boundary conditions odebvp4cMATLABodeode45simulink

H'''' – 5(H*H''' + 4GG') = 0 ; G'' + 5(H'*G – H*G') = 0 With the boundary conditions: G(0) = 0.5, H(0) = 0, H'(0) = 0,G(1) = 1, H(1) = 0, H'(1) = 0
This is my code:
function bvp_code_matlab_1
options = bvpset('stats','off', 'RelTol', 1e-6);
solinit = bvpinit(linspace(0,4,5),[1,0]);
sol = bvp4c (@OdeBVP, @OdeBC, solinit, options);
plot (sol.x, sol.y(1,:));
function f = OdeBVP(x,y)
f=[
x(2);
x(3);
20*y(1)*y(2)+5*(x(1)*x(3));
y(2);
5*(x(1)*y(2))- 5*(x(2)*y(1));
];
% Define Boundary conditions
function res = OdeBC (ya,yb)
res = [ya(1)-0.5
yb(1)-1
xa(1)
xb(1)
xa(2)
xb(2)
];
Could someone please tell me the errors I'm committing?

Best Answer

function main
options = bvpset('stats','off', 'RelTol', 1e-6);
solinit = bvpinit(linspace(0,1,500),[1,0,0,0,0,0]);
sol = bvp4c (@OdeBVP, @OdeBC, solinit, options);
plot (sol.x, sol.y(1,:));
end
% Define ODE
function f = OdeBVP(x,y)
f=[y(2);y(3);y(4);5*(y(1)*y(4)+4*y(5)*y(6));y(6);-5*(y(2)*y(5)-y(1)*y(6))];
end
% Define Boundary conditions
function res = OdeBC (ya,yb)
res = [ya(5)-0.5;yb(5)-1.0;ya(1);ya(2);yb(1);yb(2)]
end