简体   繁体   English

为什么会出现“The boundary condition function BCFUN should return a column vector of length 5”的错误信息?

[英]Why " The boundary condition function BCFUN should return a column vector of length 5" error message is came?

在此处输入图像描述

function Y6
solinit = bvpinit(linspace(0,1),[0;3;1;1],2);

sol = bvp4c(@ode, @bc, solinit);
y = sol.y;
time = sol.parameters*sol.x;
ut = -y(4,:);

figure(1);
plot(time,y([1 2],:)','-'); hold on;
plot(time, ut, 'k:');
axis([0 time(1,end) -1.5 3]);
text(1.3,2.5,'x_1(t)');
text(1.3,.9,'x_2(t)');
text(1.3,-.5,'u(t)');
xlabel('time');
ylabel('states');
title('Numerical solution');
hold off;

% -------------------------------------------------------------------------
% ODE's of augmented states
function dydt = ode(t,y,T)
dydt = T*[2*y(2);4*y(4);0;-2*y(3)];

% -------------------------------------------------------------------------
% boundary conditions: x1(0)=11;p2(0)=2; x2(tf)=3; 3*p1(tf)+p2(2)^2=0
function res = bc(ya,yb,T)
res = [ ya(1) - 11; ya(4); yb(2) - 3; 3*yb(3)+yb(4)^2];

I don't know why The boundary condition function BCFUN should return a column vector of length 5 error message is came.我不知道为什么 The boundary condition function BCFUN should return a column vector of length 5 报错信息来了。 Can you explain to me please?你能给我解释一下吗? Thank you so much太感谢了

The unknown parameters or constants, here T , also count as components.未知参数或常量,此处为T ,也算作组件。 Thus your state has overall 4+1=5 components, requiring the setting of 5 boundary conditions.因此,您的 state 总共有 4+1=5 个组件,需要设置 5 个边界条件。

Sometimes that is obvious, for instance in a Sturm-Liouville eigenvalue computation with the eigenvalue as parameter you want to avoid the zero solution, so demand that, eg, the square integral has value 1.有时这是显而易见的,例如在以特征值作为参数的 Sturm-Liouville 特征值计算中,您希望避免零解,因此要求平方积分的值为 1。

In a ballistic shot with the flight time as parameter where you fix the location of the canon and the target as obvious boundary conditions it is not that obvious what to select as additional BC, but possibilities are to fix the initial speed or the initial angle.在以飞行时间为参数的弹道射击中,您将佳能和目标的位置固定为明显的边界条件,将 select 作为附加 BC 的内容并不那么明显,但可能会固定初始速度或初始角度。


I might be rusty, but I get from the variation of我可能生疏了,但我从

L = 3*(x1(T)-9)^2 + integral(0,T, 2*u^2 +p^T*(F(x,u)-x') )

the saddle point conditions鞍点条件

T    : 0 = 12*x2(T)*(x1(T)-9) + 2*u(T)^2    (BC5)
x(t) : 0 = p'(t)+F_x(x,u)^T*p
       p1'(t) = -2*p2(t)                    (DE3)
       p2'(t) = 0                           (DE4)
p(t) : x'(t) = F(x,u)
       x1'(t) = 2*x2(t)                     (DE1)
       x2'(t) = 4*u(t)                      (DE2)
u(t) : 0 = 4*u + p^T*F_u(x,u)
       u(t) = -p2(t)                        (OPT)
x1(T): -p1(T)+6*(x1(T)-9)                   (BC3)
x2(0): 0 = p2(0)                            (BC4)

This can be directly evaluated as p2=-u=0 (BC4+DE4+OPT) are constant, likewise p1 = 6*(x1(T)-9) (BC3+DE3).这可以直接计算为p2=-u=0 (BC4+DE4+OPT) 是常量,同样p1 = 6*(x1(T)-9) (BC3+DE3)。 This in turn forces x1(T)=9 (BC5) As now x2(t)=3 is constant, we get x1(t)=11+6*t .这反过来又迫使x1(T)=9 (BC5) 由于现在x2(t)=3是常数,我们得到x1(t)=11+6*t Then the remaining expression of the functional 3*(2+6*T)^2 is minimal for T=-1/3 .然后函数3*(2+6*T)^2的剩余表达式对于T=-1/3是最小的。 For T=0 the minimal value of the functional is L=12 .对于T=0 ,泛函的最小值为L=12

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM