CAD/CAM技术及应用
%PPINTERP ppform interpretation.
switch method(1)
case 'n' % nearest
breaks = [xCol(1); ...
(xCol(1:end-1)+xCol(2:end))/2; ...
xCol(end)].';
coefs = yMat.';
pp = mkpp(breaks,coefs,ds);
case 'l' % linear
breaks = xCol.';
page1 = (diff(yMat)./repmat(diff(xCol),[1, prodDs])).'; page2 = (reshape(yMat(1:end-1,:),[n-1, prodDs])).'; coefs = cat(3,page1,page2);
pp = mkpp(breaks,coefs,ds);
case {'p', 'c'} % pchip and cubic
pp = pchip(xCol.',reshape(yMat.',[ds, n]));
case 's' % spline
pp = spline(xCol.',reshape(yMat.',[ds, n]));
case 'v' % v5cubic
b = diff(xCol);
if norm(diff(b),Inf) <= eps(norm(xCol,Inf))
% data are equally spaced
a = repmat(b,[1 prodDs]).';
yReorg = [3*yMat(1,:)-3*yMat(2,:)+yMat(3,:); ... yMat; ...
3*yMat(n,:)-3*yMat(n-1,:)+yMat(n-2,:)]; y1 = yReorg(1:end-3,:).';
y2 = yReorg(2:end-2,:).';
y3 = yReorg(3:end-1,:).';
y4 = yReorg(4:end,:).';
breaks = xCol.';
page1 = (-y1+3*y2-3*y3+y4)./(2*a.^3);
page2 = (2*y1-5*y2+4*y3-y4)./(2*a.^2);
page3 = (-y1+y3)./(2*a);
page4 = y2;
coefs = cat(3,page1,page2,page3,page4);
pp = mkpp(breaks,coefs,ds);
else
% data are not equally spaced
pp = spline(xCol.',reshape(yMat.',[ds, n]));
end
otherwise