📄 hermiteint.m
字号:
%% Compute Hermite interpolation polynomial.%% function [a] = HermiteInt( x, f )%% input:% x: vector containing the % interpolation points% f: vector containing the values % to be interpolated%% output:% a: vector of coefficients of Newton's % interpolating polynomial%%function [a] = HermiteInt( x, f );N = size(x(:),1);if size(f(:),1) ~= N ifail = 1; returnendA = zeros(N,N);% Compute first column of divided difference tablez = x(1);A(1,1) = f(1); i1 = 1; % New interpolation point appears first at index i1 for j = 2:N if ( z == x(j) ) A(j,1) = f(i1); end if ( z ~= x(j) ) z = x(j); % New interpolation point i1 = j; A(j,1) = f(i1); endend % Compute remaining columns of the divided differences tablefac = 1;for j = 2:N fac = fac * (j-1); % fac = (j-1)! i1 = j; % first time equal nodes are detected for i = j:N if ( x(i) == x(i-j+1) ) A(i,j) = f(i1) / fac ; end if ( x(i) ~= x(i-j+1) ) i1 = i+1; A(i,j) = ( A(i,j-1) - A(i-1,j-1) ) / (x(i) - x(i-j+1)) ; end endendfor j = 1:N a(j) = A(j,j);endA
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -