Using IF statement in BVP4C
1 view (last 30 days)
Show older comments
I am using BVP4C to solve my BVP. I understand how to set the various functions to use BVP4C. My questoin is as follows. My DE has a constant added to it when x<0 and a different constant added when x>0. My odefunc(x,y) file looks as follows.
function dydx = odefunc(x,y)
%constant defined in problem a = .9; sig = 2; h = 2; c = 3; p = 1; g = 2;
y = [y(1);y(2)];
A = [0 1; 2*a/(sig^2) 2/(sig^2)*((g)/g+1)^(g+1)*(1/(y(1)+c))^(g+1)]; %The Diff eq
constant_xneg = [ 0; -(2/sig^2)*(p-a*c)];%The negative case
constant_xpos = [0;(2/sig^2)*(h+a*c)]; %The positive case
if x>0
dydx = A*y + constant_xpos;
elseif x<0
dydx = A*y + constant_xneg;
else
dydx = A*y;
end
end
I was wondering if using an IF statement actually passes the DE to the solver I want???
Sonny
0 Comments
Answers (0)
See Also
Categories
Find more on Boundary Value Problems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!