1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB:Please Help with My Fixed Point Iteration Program

  1. Apr 18, 2010 #1
    1. The problem statement, all variables and given/known data
    Fixed Point Iteration matlab program

    2. Relevant equations
    To test for convergence: abs(g'(x))<1

    3. The attempt at a solution

    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)

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

    function Xs = FixedIterationRoot3(FUN3,Xest,imax)
    syms x FUN3 FunDer3
    FunDer3 = diff(FUN3) % To find g'(x)

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

    for i=2:imax

    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
  2. jcsd
  3. Apr 19, 2010 #2


    User Avatar

    In your test for divergence you should attribute a value to Xs before returning.
    Also the printf command should come before return, otherwise it will not be executed.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: MATLAB:Please Help with My Fixed Point Iteration Program