function [j, a,b,c,d, ierr] = evalB(t,x); % % Evaluates Bsplines at value t in the interval % [x(1) : x(n)] with equally spaced points x(j) % n = length(x); ierr = 0; if (t < x(1) | t > x(n)), ierr = 1; return; end h = x(2) - x(1); j = 1; while (t > x(j)), j = j+1; end if(j > 1), j = j - 1; end % % t is in [x(j),x(j+1)) % % evaluate the four B_k(t) values that % are nonzero on this interval % z = (x(j+1) - t)/h; a = z^3; b = 1 + 3*z + 3*z^2 - 3*z^3; z = (t - x(j))/h; c = 1 + 3*z + 3*z^2 - 3*z^3; d = z^3;