CAD/CAM技术及应用
s3 = s.*s2;
% Add extra points for first and last interval
yMat = [3*yMat(1,:)-3*yMat(2,:)+yMat(3,:); ... yMat; ...
3*yMat(n,:)-3*yMat(n-1,:)+yMat(n-2,:)]; for j = 1:prodDs
yiMat(p,j) = (yMat(k,j).*(-s3+2*s2-s) + ... yMat(k+1,j).*(3*s3-5*s2+2) + ...
yMat(k+2,j).*(-3*s3+4*s2+s) + ...
yMat(k+3,j).*(s3-s2))/2;
end
else
% Data are not equally spaced
% spline is oriented opposite to interp1
yiMat = spline(xCol.',yMat.',xiCol.').';
end
otherwise
error('MATLAB:interp1:InvalidMethod','Invalid method.') end
end
% Override extrapolation
if ~isequal(extrapval,'extrap')
if ischar(extrapval)
error('MATLAB:interp1:InvalidExtrap', 'Invalid extrap option.') elseif ~isscalar(extrapval)
error('MATLAB:interp1:NonScalarExtrapValue',...
'EXTRAP option must be a scalar.')
end
if isempty(p)
p = 1 : numelXi;
end
outOfBounds = xiCol<xCol(1) | xiCol>xCol(n);
yiMat(p(outOfBounds),:) = extrapval;
end
% Reshape result, possibly to an ND array
yi = reshape(yiMat,siz_yi);
varargout{1} = yi;
%-------------------------------------------------------------------------%
function pp = ppinterp