Hi jack,
You can efficiently evaluate a bivariate B-spline surface at many arbitrary (x, y) points without a for-loop by using MATLAB's fnval function in a vectorized manner. The key is to pass your x and y coordinates as row vectors inside a cell array to fnval, which will then return the estimated z-values for all points at once. This is much faster and cleaner than looping through each point. For example, if your random 3D points are stored in pts, you can compute all estimated surface z-values like this:
zEst = fnval(spmak({knotsx, knotsy}, coefs), {pts(:,1).', pts(:,2).'});
zEst = zEst(:); % Ensure it's a column vector
This approach avoids the need for a for-loop entirely and leverages MATLAB's optimized spline evaluation routines. There's no need to use spcol directly for this task, as fnval handles the details internally and works correctly for scattered input points.