# Thread: poorly explaind Matlab error

1. ## poorly explaind Matlab error

function[x,ss,n]=c3jacobi(N,a,x0,eps,maxit)
if nargin<5, maxit=100;end
if nargin<4, eps=1.0E-6;end;
if nargin<3, error('at least 3 nargin');end;
n=0;
for l=1:maxit
n=n+1;
for k=1:N
sum=0;
for j=1:N
if j~=k, sum=sum+a(k,j)*x0(j);end;
end;
x(k)=(a(k,N+1)-sum)/a(k,k);
end;
ss=0;
for k=1:N
if abs(x(k)-x0(k))>ss
ss=abs(x(k)-x0(k));
end;
end;
if ss<eps,break;end;
for k=1:N,x0(k)=x(k);end;
end;
But when I press F5 button to run, the Mathlab appeared this error : ??? Error using ==> c3jacobi at 4

2. Originally Posted by votranphu
function[x,ss,n]=c3jacobi(N,a,x0,eps,maxit)
if nargin<5, maxit=100;end
if nargin<4, eps=1.0E-6;end;
if nargin<3, error('at least 3 nargin');end;
n=0;
for l=1:maxit
n=n+1;
for k=1:N
sum=0;
for j=1:N
if j~=k, sum=sum+a(k,j)*x0(j);end;
end;
x(k)=(a(k,N+1)-sum)/a(k,k);
end;
ss=0;
for k=1:N
if abs(x(k)-x0(k))>ss
ss=abs(x(k)-x0(k));
end;
end;
if ss<eps,break;end;
for k=1:N,x0(k)=x(k);end;
end;
But when I press F5 button to run, the Mathlab appeared this error : ??? Error using ==> c3jacobi at 4
Post this in a new thread, and give the calling code.

CB

3. I don't know about mathlab, I just typed the code in book, and press F5 button to run. So, it gave the error. What can I do?

4. Originally Posted by votranphu
I don't know about mathlab, I just typed the code in book, and press F5 button to run. So, it gave the error. What can I do?
What arguments did you pass to c3jacobi ??

CB

5. Originally Posted by CaptainBlack
What arguments did you pass to c3jacobi ??

CB
The code I typed be appeared in one of my subject : Method of calculating. So, I want to solve the system of the provincial by Jacobi method. But, with my little knowledge about mathlab, I can't sovle it.

6. Originally Posted by votranphu
The code I typed be appeared in one of my subject : Method of calculating. So, I want to solve the system of the provincial by Jacobi method. But, with my little knowledge about mathlab, I can't sovle it.
c3jacobi is a function it requires at least three arguments N, a, x0.

If you did not give it these it cannot do anything.

CB