Advertisement
paulogp

Metodo da Secante

Aug 7th, 2011
1,379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.48 KB | None | 0 0
  1. function [] = secante(funcao, a, b, erro, max)
  2. % paulogp
  3. % metodo da secante
  4.     disp(' ');
  5.     % passar para funcao
  6.     f = inline(funcao);
  7.     min = 0;
  8.     d = 100;
  9.    
  10.     while ((min<max) && (d>erro))
  11.         c = f(a)/f(b);
  12.         d = ((a-b)*c)/(1-c);
  13.         g = b-d;
  14.         min = min+1;
  15.         a = b;
  16.         b = g;
  17.        
  18.         f(a) = f(b);
  19.         f(b) = f(g);
  20.        
  21.         disp(' ');
  22.         disp(['g = ' mat2str(g)]);
  23.         disp(' ');
  24.     end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement