Advertisement
Guest User

interpolacja

a guest
May 20th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.49 KB | None | 0 0
  1. function w = interpolacja_lagrangea( x, y )
  2. %INTERPOLACJA_LAGRANGEA  
  3. %
  4.     if(length(x) ~= length(y))
  5.         disp('liczba wspó³rzêdnych x-owych nie jest równa liczbie wspó³rzêdnych y-kowych');
  6.     else
  7.         N = length(x);
  8.         w = 0;
  9.         for i = 1:N
  10.             P = 1;
  11.             for j = 1:N
  12.                 if j~=i
  13.                     P = conv(P,[1 -x(j)])/(x(i) - x(j));
  14.                 end
  15.             end
  16.             w = w + y(i) * P;
  17.         end
  18.     end
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement