how do i correct this error in command bvp4c?
Show older comments
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.
Accepted Answer
More Answers (1)
Stefany Rodriguez
on 29 May 2017
Edited: Walter Roberson
on 29 May 2017
2 Comments
Walter Roberson
on 29 May 2017
The code
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];
returns a column vector of length 12, but it needs to return a column of length 6.
The length of the column vectors returned by ex1ode and ex1bc need to be the same as the length of the initial condition [0 0 0 0 0 1]
Stefany Rodriguez
on 29 May 2017
Categories
Find more on Boundary Value Problems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!