Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Help with bvp4c
Replies: 3   Last Post: Sep 18, 2013 6:33 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Midhun

Posts: 8
Registered: 8/18/09
Help with bvp4c
Posted: Sep 15, 2013 7:31 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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...



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.