Using IF statement in BVP4C
古いコメントを表示
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 件)
カテゴリ
ヘルプ センター および File Exchange で Boundary Value Problems についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!