SHARE
TWEET

T2 - CalcNum

leehcaabral Jun 23rd, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. x = [-2,-1,0,1,2,3,4];  
  2. y = [-14,0.5,3.1,0,-3,0,16];  
  3. n=length(x);
  4. #inicializando a tabela  
  5. T = zeros(n,n);  
  6. #primeira coluna  
  7. T(:,1)=y;  
  8. #segunda coluna  
  9. for j = 2:n
  10.   T(j,2)=(T(j,1)-T(j-1,1))/(x(j)-x(j-1));  
  11.   for k = 3:n
  12.   #terceira coluna  
  13.     T(k,3)=(T(k,2)-T(k-1,2))/(x(k)-x(k-2));  
  14.     for m = 4:n
  15.       #quarta coluna  
  16.       T(m,4)=(T(m,3)-T(m-1,3))/(x(m)-x(m-3));
  17.       for q = 5:n
  18.         #quinta coluna
  19.         T(q,5)=(T(q,4)-T(q-1,4))/(x(q)-x(q-4));
  20.         for r = 6:n
  21.           #sexta coluna
  22.           T(r,6)=(T(r,5)-T(r-1,5))/(x(r)-x(r-5));
  23.           for s = n
  24.             #setima coluna
  25.             T(s,7)=(T(s,6)-T(s-1,6))/(x(s)-x(1));
  26.           endfor
  27.         endfor
  28.       endfor
  29.     endfor
  30.   endfor
  31. endfor
  32. T
  33.  
  34. p = T(1,1) + T(2,2)*(x-x(1)) + T(3,3)*(x-x(1))*(x-x(2)) + T(4,4)*(x-x(1))*(x-x(2))*(x-x(3)) + T(5,5)*(x-x(1))*(x-x(2))*(x-x(3))*(x-x(4)) + T(6,6)*(x-x(1))*(x-x(2))*(x-x(3))*(x-x(4))*(x-x(5)) + T(7,7)*(x-x(1))*(x-x(2))*(x-x(3))*(x-x(4))*(x-x(5))*(x-x(6))
  35. p
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top