Results 1 to 3 of 3

Math Help - MatLab - Joining The Dots.

  1. #1
    Super Member
    Joined
    Dec 2008
    From
    Scotland
    Posts
    901

    MatLab - Joining The Dots.

    Hi folks.

    I have plotted a graph in matlab. The graph is the result of Newton's Method. My y axis has  r(x_1), r(x_2)... etc . There are actually only 5 of these values. My x axis is a counter for the number of times the loop was performed. Again, there are only 5 of these.

    So as you can imagine, my plot, which is supposed to denote convergence, has only 5 points. Is there a way to get matlab to join them up so there is something to LOOK at on this graph haha?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member
    Joined
    Dec 2008
    From
    Scotland
    Posts
    901
    In fact, how do I get the plot to plot ALL values!

    Code:
    i = 1;
    % Define first index.
    x = 1;
    %Define first point for method.
    f = @(x) (x - sin(x)-1);
    %Define function.
    df = @(x) (1-cos(x));
    %Define derivative of function.
    
    %Loop carries out Newton's Method.
    while abs(f(x)/df(x)) > 0.000001
        x = x - (f(x)/df(x));
        i = i+1;
    end
    %Display the solution in long format.
    format long
    x
    Here's my script without any plotting being done. The program gives the final value of x correctly. But how can I get it to plot the initial values I gave it, aswell as each intermediate value in Newton's Method?
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Super Member
    Joined
    Dec 2008
    From
    Scotland
    Posts
    901
    Nevermind, I got it folks!

    Thanks anyway.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Three dots meaning therefore.
    Posted in the LaTeX Help Forum
    Replies: 1
    Last Post: February 27th 2011, 03:32 AM
  2. line joining
    Posted in the Algebra Forum
    Replies: 2
    Last Post: May 28th 2010, 07:13 PM
  3. Line representing coordinate dots?
    Posted in the Algebra Forum
    Replies: 2
    Last Post: May 13th 2008, 07:40 AM
  4. grid dots
    Posted in the Discrete Math Forum
    Replies: 0
    Last Post: April 17th 2007, 10:13 AM

Search Tags


/mathhelpforum @mathhelpforum