please help me with this

1 回表示 (過去 30 日間)
arsalan mehrabi
arsalan mehrabi 2021 年 1 月 9 日
コメント済み: arsalan mehrabi 2021 年 1 月 9 日
i found this code on internet and its error is 'Not enough input arguments'.
how can i solve this?
Not enough input arguments.
Error in tridiag (line 3)
n = length(d); % n is the number of rows
function x = TDMAsolver(a,b,c,d)
%a, b, c are the column vectors for the compressed tridiagonal matrix, d is the right vector
n = length(d); % n is the number of rows
% Modify the first-row coefficients
c(1) = c(1) / b(1); % Division by zero risk.
d(1) = d(1) / b(1);
for i = 2:n-1
temp = b(i) - a(i) * c(i-1);
c(i) = c(i) / temp;
d(i) = (d(i) - a(i) * d(i-1))/temp;
end
d(n) = (d(n) - a(n) * d(n-1))/( b(n) - a(n) * c(n-1));
% Now back substitute.
x(n) = d(n);
for i = n-1:-1:1
x(i) = d(i) - c(i) * x(i + 1);
end
(matlab 2020a)
  1 件のコメント
Sibi
Sibi 2021 年 1 月 9 日
what input you gave?

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

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 1 月 9 日
You have not called TDMAsolver with all the inputs. Notice that it requires four inputs (a,b,c and d).
  3 件のコメント
Cris LaPierre
Cris LaPierre 2021 年 1 月 9 日
The code is fine. You just need to call it correctly.
arsalan mehrabi
arsalan mehrabi 2021 年 1 月 9 日
thanks man

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by