⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newton.m

📁 a m file for matlab the secant method
💻 M
字号:
function rtn=newton(fx,dfx,x0,tol,N)
% Secant Method
% The first parameter fx is a external function with respect to viable x.
% x0, x1 are initial iteration points.
% tol is the tolerance of the loop.
% N is the maximum number of iterations.
x=x0;f0=eval(fx);df0=eval(dfx);
n=0;


   while n<=N
      x1=x0-f0/df0;
      x=x1;f1=eval(fx);df1=eval(fx)
      X=[n,x0,x1,f1];
      disp(X);
      if abs(x1-x0)<tol
          fprintf('The procedure was successful.')
          return
      else
          n=n+1; x0=x1;f0=f1;
      end
   end

  if n==N+1
    fprintf('the method failed after N iterations. ')
 end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -