Date: Sep 15, 2013 7:31 PM
Author: Midhun
Subject: Help with bvp4c
Hi all,

I have a 2nd order equation given by:

C" + i/(C+ r) *( C/(C+r) - 1 ) C' - k* C = 0

where C = C(x),

i, r,k are constants.

Boundary conditions:

C(0) = 1;

C'(1) = 1/(1 + r/C).

I was trying to use bvp4c for this problem by converting them to a set of ODEs, but couldn't make out how to specify the 2nd boundary condition.

Set of ODEs:

C' = P

P' = -i/(C+r) * (C/C+r - 1)*P +k*C

BCs : C(0) = 1;

P(1) = i/(1+r/C)

My code:

solinit = bvpinit([0,1],[0,0]);

sol = bvp4c(@deriv,@bcs,solinit);

plot(sol.x,sol.y(1,:),'b-x',sol.x,sol.y(2,:),'g-x');

%------------------

function dYdx = deriv(x,Y)

i = 1;r = 1;

k = 1;

dYdx = zeros(2,1);

dYdx(1) = Y(2);

dYdx(2) = -i/(Y(1)+r) * (Y(1)/(Y(1)+r) - 1)*Y(2) + k * Y(1);

%-----------------

function res = bcs(ya,yb)

i = 1;

r = 1;

res = [ ya(1) - 1

???? ];

Could anyone help me on I can specify the 2nd B.C which is a function of C ?

Thanks in advance...