Graphics Programs Reference
In-Depth Information
- 6*(yData(2:n-1) - yData(3:n))...
./(xData(2:n-1) - xData(3:n));
[c,d,e] = LUdec3(c,d,e);
k = LUsol3(c,d,e,k);
splineEval
The function splineEval computes the interpolant at x fromEq. (3.10). The sub-
function findSeg finds the segment of the splinethatcontains x by the method
of bisection. It returns the segment number; that is, the value of the subscript i in
Eq. (3.10).
functiony=splineEval(xData,yData,k,x)
% Returns value of cubic spline interpolant at x.
%USAGE:y=splineEval(xData,yData,k,x)
% xData = x-coordinates of data points.
% yData = y-coordinates of data points.
%k
=curvaturesofsplineattheknots;
%
returned by function splineCurv.
i = findSeg(xData,x);
h = xData(i) - xData(i+1);
y = ((x - xData(i+1))ˆ3/h - (x - xData(i+1))*h)*k(i)/6.0...
- ((x - xData(i))ˆ3/h - (x - xData(i))*h)*k(i+1)/6.0...
+ yData(i)*(x - xData(i+1))/h...
- yData(i+1)*(x - xData(i))/h;
functioni=findSeg(xData,x)
% Returns index of segment containing x.
iLeft = 1; iRight = length(xData);
while 1
if(iRight - iLeft) <= 1
i = iLeft; return
end
i = fix((iLeft + iRight)/2);
ifx<xData(i)
iRight = i;
else
iLeft = i;
end
end
Search WWH ::




Custom Search