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
Mostrar comentarios más antiguos
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 comentarios
dpb
el 12 de Sept. de 2015
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.
Star Strider
el 12 de Sept. de 2015
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?
Respuestas (0)
Categorías
Más información sobre Shifting and Sorting Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!