Passing parameters in boundary value problem using BVP4C
古いコメントを表示
For a system of boundary value problems I need to pass a parameter as a coefficient. Let's assume that I have defined the problem as:
solinit = bvpinit(linspace(0,10,50),[0 10]);
sol = bvp4c(@twoode,@twobc,solinit,a);
x = linspace(0,4);
y = deval(sol,x);
function dydx = twoode(x,y,a)
dydx = [ y(2); -a*exp(-x)+x*exp(-x)];
end
function res = twobc(ya,yb,a)
res = [ya(1); yb(1)-10*exp(-10)];
end
Where a is the parameter, and my first try was to add a to all the functions involved, but I receive the "Not enough input arguments" error. Is there a way to include the parameter a in the problem?
採用された回答
その他の回答 (1 件)
Stephan
2019 年 12 月 1 日
0 投票
See here: passing extra parameters. I suggest to either use the anonymous functions or the nested functions approach. Both is easy to apply.
カテゴリ
ヘルプ センター および File Exchange で Boundary Value Problems についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!