Results 1 to 5 of 5

Math Help - MATLAB:Please Help with My Fixed Point Iteration Program

  1. #1
    Newbie
    Joined
    Apr 2010
    Posts
    3

    MATLAB:Please Help with My Fixed Point Iteration Program

    Hi all, I am trying to write a Fixed Point Iteration program but when I enter in the command line it kept giving me an error message. Can you please look over my program and tell me what might have gone wrong? Thank you very much!

    First, I defined a function in a new M-File:

    function y=FUN3(x)
    y=5/(sin(x)*exp(-x./2));

    Then, I opened up another M-File and wrote the program:

    function Xs = FixedIterationRoot3(FUN3,Xest,imax)
    syms x FUN3 FunDer3
    Xi(1)=Xest;
    FUN3=5/(sin(x)*exp(-x./2));
    FunDer3 = diff(FUN3) % To find g'(x)

    if abs(subs(FunDer3,x,Xest))>=1 % to check if g'(x) diverges
    return;
    fprintf('not valid')
    end

    for i=2:imax
    Xi(i)=feval(FUN3,Xest);
    Xest=Xi(i);
    Xs=Xi;
    end

    When I enter in the command line:
    >> xSolutions=FixedIterationRoot3('FUN3',-3,10)

    it gave me error message:
    syms x FUN3 FunDer3

    ??? Output argument "Xs" (and maybe others) not assigned during call
    to
    "C:\Users\Jane\Documents\MATLAB\FixedIterationRoot 3.m>FixedIterationRoot3".

    Can you please help me fix something that is wrong or suggest an alternate method for Fixed Point Iteration?

    I GREATLY APPRECIATE YOUR TIME!
    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 pjkily View Post
    Hi all, I am trying to write a Fixed Point Iteration program but when I enter in the command line it kept giving me an error message. Can you please look over my program and tell me what might have gone wrong? Thank you very much!

    First, I defined a function in a new M-File:

    function y=FUN3(x)
    y=5/(sin(x)*exp(-x./2));

    Then, I opened up another M-File and wrote the program:

    function Xs = FixedIterationRoot3(FUN3,Xest,imax)
    syms x FUN3 FunDer3
    Xi(1)=Xest;
    FUN3=5/(sin(x)*exp(-x./2));
    FunDer3 = diff(FUN3) % To find g'(x)

    if abs(subs(FunDer3,x,Xest))>=1 % to check if g'(x) diverges
    return;
    fprintf('not valid')
    end

    for i=2:imax
    Xi(i)=feval(FUN3,Xest);
    Xest=Xi(i);
    Xs=Xi;
    end

    When I enter in the command line:
    >> xSolutions=FixedIterationRoot3('FUN3',-3,10)

    it gave me error message:
    syms x FUN3 FunDer3

    ??? Output argument "Xs" (and maybe others) not assigned during call
    to
    "C:\Users\Jane\Documents\MATLAB\FixedIterationRoot 3.m>FixedIterationRoot3".

    Can you please help me fix something that is wrong or suggest an alternate method for Fixed Point Iteration?

    I GREATLY APPRECIATE YOUR TIME!
    Do not use FUN3 for both a symbolic object and a .m function.

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Apr 2010
    Posts
    1
    I need help with that problem too! ECM 6?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Apr 2010
    Posts
    3
    Quote Originally Posted by mcnuggets View Post
    I need help with that problem too! ECM 6?
    yeaaa, haha we're on the same boat
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Apr 2010
    Posts
    3
    Quote Originally Posted by CaptainBlack View Post
    Do not use FUN3 for both a symbolic object and a .m function.

    CB
    so I fixed my program:
    function Xs = FixedIterationRoot3(FUN3,Xest,imax)
    syms x
    Xi(1)=Xest;
    FunDer3 = diff('FUN3');

    if abs(subs(FunDer3,x,Xest))>=1
    return;
    fprintf('this function does not converge')
    end
    for i=2:imax
    Xi(i)=feval(FUN3,Xest);
    Xest=Xi(i);

    end
    Xs=Xi;





    Apparently, this gives me the same error. I've also noticed that if I do this :
    syms x
    Xi(1)=Xest;
    FunDer3 = diff('FUN3');

    it doesn't give me the right derivative, it gives me the number 1. How can I fix this to get the symbolic derivative?
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Fixed point iteration help
    Posted in the Advanced Math Topics Forum
    Replies: 8
    Last Post: November 8th 2011, 11:19 AM
  2. Fixed point iteration
    Posted in the Differential Geometry Forum
    Replies: 13
    Last Post: October 21st 2010, 03:36 AM
  3. fixed point iteration question with matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: March 7th 2010, 12:34 PM
  4. Fixed point iteration
    Posted in the Advanced Math Topics Forum
    Replies: 0
    Last Post: February 2nd 2010, 07:30 AM
  5. Fixed Point Iteration
    Posted in the Differential Geometry Forum
    Replies: 1
    Last Post: November 12th 2009, 12:40 PM

Search Tags


/mathhelpforum @mathhelpforum