function v = pchiptx(x,y,u) %PCHIPTX Textbook piecewise cubic Hermite interpolation. % v = pchiptx(x,y,u) finds the shape-preserving piecewise cubic % interpolant P(x), with P(x(j)) = y(j), and returns v(k) = P(u(k)). % % See PCHIP, SPLINETX. % First derivatives h = diff(x); delta = diff(y)./h; d = pchipslopes(h,delta); % Piecewise polynomial coefficients n = length(x); c = (3*delta - 2*d(1:n-1) - d(2:n))./h; b = (d(1:n-1) - 2*delta + d(2:n))./h.^2; % Find subinterval indices k so that x(k) <= u < x(k+1) k = ones(size(u)); for j = 2:n-1 k(x(j) <= u) = j; end % Evaluate interpolant s = u - x(k); v = y(k) + s.*(d(k) + s.*(c(k) + s.*b(k))); % ------------------------------------------------------- function d = pchipslopes(h,delta) % PCHIPSLOPES Slopes for shape-preserving H
Matlab pchiptx
最新推荐文章于 2022-06-10 13:58:44 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)