Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [ output ] = wielomianLagrangea( X , Y )
- %x[-2,-1,0,2]
- %y[0,1,1,2]
- %x^3/6 - x/6 + 1
- syms x;
- n = length(X);
- output = 0;
- for i = 1:n;
- y=1;
- for j = 1:n
- if j~=i
- y = y * (x-X(j))/(X(i)+X(j));
- end
- end
- y = y * Y(i)
- output = output + y;
- end
- output = simplify(output);
- f = @(X)eval(output)
- z = x(1)-1:0.1:x(n)+1;
- plot(z,f(z),x,y,'v');
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement