MATLAB: How do i correct this error in command bvp4c

.boundary conditionsbvp4cprogramprograming

the optimal control i used the command BVP4C but i don't use because generates me a this error
my code is:
function dydx = ex1ode(x,y)
dydx = [y(2)
-2.2727*y(1)+ (-1.1364)*y(2)+(0.0136)*y(3)
(-11)*y(2)+(-40)*y(3)+(1000)*((-1000*y(6))/2*1)
(-2.2727)*y(5),y(4)+((-1.1364)*y(5))+(-11*y(6))
(-1.1364*y(5))+(-40*y(6))];
the other function is
function res = ex1bc(ya,yb)
res = [ ya(1); yb(1)-1
ya(2); yb(2)-10
ya(3); yb(3)-1
ya(4); yb(4)-1
ya(5); yb(5)-1
ya(6); yb(6)-1];
and the principal program is,
clear all
clc
solinit = bvpinit(linspace(0,18,6),[0 0 0 0 0 1])
sol = bvp4c(@ex1ode,@ex1bc,solinit);
x = linspace(0,4);
y = deval(sol,x);
plot(x,y(1,:))
I don't know which the problem
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Error in ex1ode (line 3)
dydx = [y(2)
Error in bvparguments (line 105)
testODE = ode(x1,y1,odeExtras{:});
Error in bvp4c (line 130)
bvparguments(solver_name,ode,bc,solinit,options,varargin);
thanks.

Best Answer

You have
dydx = [y(2)
-2.2727*y(1)+ (-1.1364)*y(2)+(0.0136)*y(3)
(-11)*y(2)+(-40)*y(3)+(1000)*((-1000*y(6))/2*1)
(-2.2727)*y(5),y(4)+((-1.1364)*y(5))+(-11*y(6))
(-1.1364*y(5))+(-40*y(6))];
Notice that in the fourth line you have
(-2.2727)*y(5),y(4)+((-1.1364)*y(5))+(-11*y(6))
that is a comma between the y(5) and y(4), and it indicates that you are putting a second value horizontally at that location, making two entries on that row but all the other rows have only one entry.
You probably need
dydx = [y(2)
-2.2727*y(1)+ (-1.1364)*y(2)+(0.0136)*y(3)
(-11)*y(2)+(-40)*y(3)+(1000)*((-1000*y(6))/2*1)
(-2.2727)*y(5)
y(4)+((-1.1364)*y(5))+(-11*y(6))
(-1.1364*y(5))+(-40*y(6))];