how do i correct this error in command bvp4c?
이전 댓글 표시
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.
채택된 답변
추가 답변 (1개)
Stefany Rodriguez
2017년 5월 29일
편집: Walter Roberson
2017년 5월 29일
댓글 수: 2
Walter Roberson
2017년 5월 29일
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
2017년 5월 29일
카테고리
도움말 센터 및 File Exchange에서 Boundary Value Problems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!