function v = seval(z,x,y,b,c,d) % Usage: v = seval(z,x,y,b,c,d) % % Evaluate natural cubic spline at z % % input: % z points at which the spline is evaluated % they are in the range [x(1), x(length(x))] % x,y coordinates to be interpolated % b,c,d coefficients returned by ncspline.m % output: % v values of the spline at z % dependency: % locate.m locator n = length(z); % g = 1; % initial guess of the location of z(1) for j=1:n i = locate(x,z(j),g); % locate z(j) % evaluate at z(j) in [x(i), x(i+1)] tmp = z(j) - x(i); v(j) = y(i)+tmp*(b(i)+tmp*(c(i)+tmp*d(i))); g = i; % guess for the next location end;