フィルターのクリア

Jacobi Iterations Coding Question

1 回表示 (過去 30 日間)
Kaylene Widdoes
Kaylene Widdoes 2015 年 10 月 6 日
回答済み: Walter Roberson 2015 年 10 月 6 日
Here's what I have so far with my code. It says that the function file is not available in this context. I am wondering what I have to put where as far as different function files and what not to make it run. Any help is appreciated.
% HW 3 - Problem 2
A=[4 1 -1; 1 -5 -1; 2 -1 -6];
B=[13 -8 -2];
P=[0,0,0];
delta=(1*(10^(-10)));
max1=10;
counter = 0;
function X=jacobi(A,B,P,delta, max1)
for k=1:max1
for j=1:N
X(j)=(B(j)-A(j,[1:j-1,j+1:N])*P([1:j-1,j+1:N]))/A(j:j);
counter = counter + 1;
end
err=abs(norm(X'-P));
relerr=err/(norm(X)+eps);
p=X';
if (err<delta)|(relerr<delta)
break
end
end
X=X'

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 10 月 6 日
As the first line of your code, add
function HW2P3
where HW2P3 must match the name of the .m file you have the code stored in.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by