-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaryeval1.m
More file actions
33 lines (27 loc) · 858 Bytes
/
baryeval1.m
File metadata and controls
33 lines (27 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
% Interpolation using the barycentric weighted form of Lagrange polynomial, w = baryweights function
function y = baryeval1(tau, rho, x)
% initialize beta as a vector of ones
beta = ones(1, length(tau));
% initialize w(x) as a vector of ones
w = ones(1, length(x));
% defining w(x), as the recursive product 1:length(tau)->(1:4)
for k = 1:length(tau)
w = w.*(x - tau(k));
end
% Defining beta function within do alternately iterate through k and j
for k = 1:length(tau)
for j = 1:length(tau)
if k ~= j
beta(k) = (beta(k)) * (1/(tau(k)-tau(j)));
end
end
end
% defining the function
f = zeros(1,length(x));
% summation of the node terms
for k = 1:length(tau)
f = f + (beta(k) * rho(k) ./ ((x-tau(k))));
end
% multiply by w
y = w.*f;
end