bvp4c guess value

1 次查看(过去 30 天)
Luke
Luke 2011-3-23
Hi,
I'm trying to solve a boundary value problem using bvp4c. My equation is as folows.
G'= k1*rw*uw;
Here k1 is a constant. rw is a known (1x100) vector. uw and G' are unknowns. The boundary conditions are
G'(0)= Ginf*0.99 and
G'(L)= Ginf*0.01;
I tried to solve this using the following code, but it gives me the following error.
"The boundary condition function BCFUN should return a column vector of length 2."
Following is my code.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [y1,uw] = testbvp
rhoW= [0.912669843 0.912669843 0.913062531 0.913082624 0.913083242 0.913083252 0.913083251 0.913083251 0.91308325 0.91308325];
a= 0.0015; Ginf= 2.3881;
options = [];
solinit = bvpinit(linspace(0,1,10),1,1);
sol = bvp4c(@testode,@testbc,solinit,options,a,rhoW,Ginf);
y1= deval(sol,x);
% -----------------------------------------------------------------
function dydx = testode(x,y,a,rhoW,~,uw)
k1= -4/a;
dydx = k1*rhoW.*uw;
% -----------------------------------------------------------------
function res = testbc(ya,yb,~,~,Ginf,~)
res = [ya(1)-Ginf*0.99
yb(1)-Ginf*0.01];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I need to find the unknown values of G' and uw. Thanks in advance.
Luke

回答(1 个)

Walter Roberson
Walter Roberson 2011-3-23
Your testode function needs to return a column vector the same size as y, but you are ignoring x (a scalar) and y (a column vector) completely. Possibly what you are doing is okay, but it looks wrong to me at the moment. Please check the size of your dydx against the size of y in testode.
I do not immediately see a reason why it would have a problem in testbc(), not unless it was finding that Ginf was the empty set. Please check the size of your inputs and outputs for testbc()

类别

Help CenterFile Exchange 中查找有关 Boundary Value Problems 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by