MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by Matthew
on 19 Nov 2012

My code works BUT I need to add 1 more thing:

- output- a vector containing the sequence of estimates including the initial guess x0,

function [ r, n ] = myNewton( fHan,dfHan,x0,fTol, itermax ) i = 1;

while abs(fHan(x0)) >= fTol r(i) = x0; n(i) = abs(fHan(x0)); i = i+1; x0 = x0-((fHan(x0))/(dfHan(x0))); end

for j = 1:itermax;

dx = fHan(r) / dfHan(r); r = r - dx

if r < fTol return end end

if abs(fHan(x0)) < fTol r(i) = x0; n(i) = abs(fHan(x0)); end

end

how do I go about doing this? thanks!!

*No products are associated with this question.*

## 1 Comment

## Matt J

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/54158#comment_112035

You and this guy have a lot in common

http://www.mathworks.com/matlabcentral/answers/54142-newton-s-method-issues