Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

How to add a Sequence of Estimates to my Newton Raphson Code? please help!!

Asked by Matthew on 19 Nov 2012

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

  1. 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!!

Matthew

Products

No products are associated with this question.

0 Answers

Contact us