Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [ W ] = WzorInterpolacyjnyNewtona( X,Y )
- %WzorInterpolacyjnyNewtona([-4,-3,-1,0,2,4],[2,-1,-37,-58,464,-3382])
- %ans: - 3*x^5 - 15*x^4 + 16*x^3 + 138*x^2 + 89*x - 58
- %WzorInterpolacyjnyNewtona
- syms x;
- R = LiczRzedy([-4,-3,-1,0,2,4],[2,-1,-37,-58,464,-3382]);
- suma = R(1,1);
- n = length(R);
- for i = 1:n-1
- V = R(1,i+1);
- for j = 1:i
- V = V * (x - X(j));
- end
- suma = suma + V;
- end
- W= simplify(suma);
- z=X(1)-1:0.1:X(n)+1;
- plot(z,subs(W,z),X,Y,'*');
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement