Piecewise Hermite Cubic Interpolation

버전 1.3.0.0 (2.24 KB) 작성자: Juan Camilo Medina
Interpolates with a Hermite cubic polynomial using the function values and corresponding derivatives
다운로드 수: 1.2K
업데이트 날짜: 2011/4/11

라이선스 보기

Piecewise Hermite cubic interpolation between 2 points knowing derivative values

Syntax: y=p3hermite(x,pointx,pointy,yprime,plt)
Where
pointx = data points of the independent variable
(The points do not have to be equally spaced)
pointy = data points of the dependent variable. pointy is the value of
the function at pointx
yprime = data points of the dependent variable's derivative. yprime is the
derivative of the function at pointx
x = an arbitrary vector that will be interpolated
plt = If plt is a number greater than 0 it will plot the interpolation
employing the number in plt as handle for the figure

-This function returns the piecewise interpolation "y" of a vector "x".
The algorithm employs two adjacent points (from pointx) and interpolates
with a Hermite cubic polynomial using the function values and the corresponding derivatives.
-pointx, pointy, and yprime must be vectors with the same number of elements.
"x" and "y" have the same number of elements.

Written by Juan Camilo Medina 2011

Example:
Suppose you have the values of a function "y(x)" at the points xi={0,4,9},
those are yi={2,-2,sqrt(2)} respectively. You also know the values of the
derivative of y(x) at the same points (pointx) yi'=[0,0,-pi/(2*sqrt(2))] respectively.
You want to interpolate within those values with an arbitrary vector "x"
using piecewise cubic Hermite polynomials
Thus:

pointx=[0,4,9];
pointy=[2,-2,sqrt(2)]; %function values at pointx
yprime=[0,0,-pi/(2*sqrt(2))]; %derivative of the function at pointx
x=0:0.01:pointx(end); % arbitrary vector to be interpolated
y=p3hermite(x,pointx,pointy,yprime,2);
y_ex=2*cos(pi/4*x); % exact value (y corresponds to y=2*cos(pi/4*x))
plot(x,y_ex,'--k'); axis tight; % plots exact solution for comparison
legend('Interpolation Points','Hermite Interpolation','Exact Value','Location','Southeast')

Written by Juan Camilo Medina - The University of Notre Dame

인용 양식

Juan Camilo Medina (2024). Piecewise Hermite Cubic Interpolation (https://www.mathworks.com/matlabcentral/fileexchange/30763-piecewise-hermite-cubic-interpolation), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2010b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.3.0.0

added a screen shot of the example

1.2.0.0

fixed a bug and added an example on how to use it.

1.1.0.0

.

1.0.0.0