Results 1 to 6 of 6

Math Help - poorly explaind Matlab error

  1. #1
    Newbie
    Joined
    May 2009
    Posts
    3

    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
    Please help me
    Last edited by CaptainBlack; May 9th 2009 at 03:14 AM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by votranphu View Post
    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
    Please help me
    Post this in a new thread, and give the calling code.

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    May 2009
    Posts
    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?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by votranphu View Post
    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
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    May 2009
    Posts
    3
    Quote Originally Posted by CaptainBlack View Post
    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.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by votranphu View Post
    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
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. MatLab - Can't understand error
    Posted in the Math Software Forum
    Replies: 0
    Last Post: May 19th 2011, 01:11 AM
  2. matlab error Hdiv, L2, H1
    Posted in the Math Software Forum
    Replies: 0
    Last Post: July 17th 2010, 08:16 AM
  3. Simpsons 3.8 rule, error help matlab
    Posted in the Math Software Forum
    Replies: 3
    Last Post: May 10th 2010, 06:31 AM
  4. MATLAB error
    Posted in the Math Software Forum
    Replies: 1
    Last Post: March 31st 2010, 10:39 AM
  5. Matlab programming error help
    Posted in the Math Software Forum
    Replies: 7
    Last Post: February 1st 2010, 07:25 PM

Search Tags


/mathhelpforum @mathhelpforum