mirror of
https://bitbucket.org/Mattrixwv/octavefunctions.git
synced 2025-12-06 18:53:57 -05:00
25 lines
877 B
Matlab
25 lines
877 B
Matlab
function [value] = LagrangeInterpolation(x_data, y_data, x)
|
|
%LagrangeInterpolation evaluates the lagrange interpolation polynomial for
|
|
%given set of data points
|
|
%
|
|
% Input
|
|
% - x_data: One-dimensional list of x-coordinates of point through
|
|
% which the interpolating polynomial will pass. The degree of the
|
|
% interpolating polynomial, n, will be inferred from the number of
|
|
% entries in x_data
|
|
% - y_data: One-dimensional list of y-coordinates of point through
|
|
% which the interpolating polynomial will pass
|
|
% - x: One-dimensional list of values for which the Lagtrange
|
|
% polynomial will be evaluated
|
|
%
|
|
% Output
|
|
% - value: Value(s) of interpolation polynomial
|
|
|
|
%Ensure that the y_data list is a row vector
|
|
y_data = y_data(:)';
|
|
|
|
%Do the interpolation
|
|
value = y_data*LagrangePolynomials(x_data, x);
|
|
end
|
|
|