# poorly explaind Matlab error

• May 8th 2009, 11:22 PM
votranphu
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
• May 9th 2009, 03:12 AM
CaptainBlack
Quote:

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
• May 12th 2009, 04:21 AM
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?(Headbang)
• May 12th 2009, 06:28 AM
CaptainBlack
Quote:

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?(Headbang)

What arguments did you pass to c3jacobi ??

CB
• May 14th 2009, 07:50 PM
votranphu
Quote:

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.(Thinking)
• May 14th 2009, 09:00 PM
CaptainBlack
Quote:

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.(Thinking)

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