Not enough input arguments Error in bvpfcn (line 5) dydx = [y(2)*(U*y​(2)+K*y(1)​)/D];

2 ビュー (過去 30 日間)
Naveen Krish
Naveen Krish 2022 年 3 月 15 日
コメント済み: Walter Roberson 2022 年 3 月 18 日
Error in bvpfcn (line 5) dydx = [y(2)*(U*y(2)+K*y(1))/D];
  5 件のコメント
Naveen Krish
Naveen Krish 2022 年 3 月 15 日
編集済み: Walter Roberson 2022 年 3 月 15 日
function dydx = ode(y,x) % equation to solve
y1 = y(1);
y2= y(2);
dy1_dx = y(2);
dy2_dx = [U*y2+K*y1/D];
dy_dx = [dy_dx; dy2_dx];
end
Torsten
Torsten 2022 年 3 月 15 日
dy_dx = [dy1_dx; dy2_dx]
instead of
dy_dx = [dy_dx; dy2_dx]

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2022 年 3 月 15 日
編集済み: Jan 2022 年 3 月 16 日
r = bvp4c(ode,bc,solinit);
% ^^^
This is a call of the function ode() without input arguments. You want to provide a function handle instead:
r = bvp4c(@ode,bc,solinit);
% ^
This will fail also:
function dydx = ode(y,x) % equation to solve
y1 = y(1);
y2= y(2);
dy1_dx = y(2);
dy2_dx = [U*y2+K*y1/D];
dy_dx = [dy_dx; dy2_dx];
end
The function replies "dydx", but you define "dy_dx". Easier:
function dydx = ode(y, x)
D = 0.1; % m2/s
U = 1; % m/s
K = 1e-6; % 1/s
dydx = [y(2); ...
(U * y(2) + K * y(1)) / D]; % EDITED, parentheses added
end
Remember that 1*10^-6 is a multiplication and an expensive power operation, while 1e-6 is a cheap constant.
  8 件のコメント
Naveen Krish
Naveen Krish 2022 年 3 月 18 日
Unrecognized function or variable 'solinit'.
Error in bvpfcn (line 1)
r = bvp4c(@ode,@bc,solinit);
Walter Roberson
Walter Roberson 2022 年 3 月 18 日
You do not appear to have assigned anything to solinit, such as by using https://www.mathworks.com/help/matlab/ref/bvpinit.html

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by