Error message using bvp4c

2 views (last 30 days)
Joe
Joe on 16 Jun 2015
Answered: Torsten on 17 Jun 2015
I'm trying to solve a single-stage rocket trajectory problem using bvp4c. Can somebody tell me why I'm getting the error message below?
"Error using bvparguments (line 111) Error in calling BVP4C(ODEFUN,BCFUN,SOLINIT): The boundary condition function BCFUN should return a column vector of length 5."
The problem seems to be in my function bvpbc. I know my initial conditions but want to force the solution on 2 final conditions while allowing the other 2 to float. I read "Solving Boundary Problems for Ordinary Differential Equations in MATLAB with bvp4c," and I think I understood the concept.
Portion of Code (copied from another computer screen so there might be typos):
DEG2RAD = pi/180;
M2KM = 1e-3;
% Initial conditions
tau = linspace(0,200,100); % time array
v0 = 0; % velocity
gamma0 = 89.85; % angle
x0 = 0; % downrange
h0 = 0; % altitude
f0 = [v0;gamma0;x0;h0];
solinit = bvpinit(tau,f0);
sol = bvp4c(@bvpFx,@bvpbc,solinit);
%--------------------------------
% Boundary conditions
function res = bvpbc(ya,yb)
global DEG2RAD M2KM
res = [ya(1);
ya(2) - 89.85*DEG2RAD;
ya(3);
ya(4);
yb(2) - 8.8*DEG2RAD;
yb(4) - 133.2/M2KM];
%--------------------------------
% ODE function
function dydt = bvpFx(tau,y)
% ... ODE code ....
Thanks!

Answers (1)

Torsten
Torsten on 17 Jun 2015
number of solution variables = number of (first-order) differential equations = number of boundary conditions.
But you prescribe 6 boundary conditions for 4 solution variables.
Best wishes
Torsten.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!