My text book gives matlab codes to copy directly, but Im trying to run a Jacobi iteration and it keeps telling me that there are not enough inputs. I have copied them from the textbook verbatin, please help me! I dont know why Im getting an error

function x = Jacobi(A,b,x0,tol,maxit)
[n, m] = size(A);
xold = x0;
C = -A;
for i = 1:n
C(i,i) = 0;
end
for i = 1:n
C(i,:) = C(i,:)/A(i,i);
end
for i = 1:n
d(i,1) = b(i)/A(i,i);
end
i = 1 ;
disp(' i x1 x2 x3 ....');
while (i <= maxit)
xnew = C * xold + d;
if norm(xnew-xold) <= tol
x = xnew;
disp('Jacobi method converged'); return;
else
xold = xnew;
end
disp(['i xnew']);
i = i + 1;
end
disp('Jacobi mmethod did not converge');
disp('results after maximum number of iterations');
x = xnew;

댓글 수: 2

You didn't supply the most key piece of information; namely the line that error'ed and the error message in context with the line. Don't paraphrase; don't retype; cut 'n paste.
Also, don't put the question in the title; make the title exactly that and that alone; save the actual question for the body.
You left out an important part of the information.
What line is throwing the error? Copy all the red text from the Command Window and paste it in a Comment here.
How are you calling Jacobi in your main script?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Function Creation에 대해 자세히 알아보기

질문:

2015년 9월 12일

댓글:

2015년 9월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by