# Thread: MatLab - Joining The Dots.

1. ## 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 $\displaystyle 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?

2. 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?

3. Nevermind, I got it folks!

Thanks anyway.

### content

Click on a term to search for related topics.