Matlab: Borehole function regression

#1
I am trying to fit a linear regression to the borehole function using latin hypercube sampling.
http://www.sfu.ca/~ssurjano/borehole.html
Outside of a narrow range of points(46-252) I get warnings about rank deficiency when I run the regress function with upto quadratic interactions. Lower than 46 obviously won't work as there are 45 predictors. Why am I having trouble with more than 252?

The code I am using:
Code:
tNorm= @(mu, sigma, L, U, N, D) norminv((1-D)*normcdf(L,mu,sigma)+D*normcdf(U,mu,sigma),mu,sigma);
n=2^8-4;
X=ones(n,1);
X(:,2:9)=lhsdesign(n,8);
X(:,2)=tNorm(0.10,0.0161812,0.05,0.15,n,X(:,2));
X(:,3)=exp(tNorm(7.71,1.0056,log(100),log(50000),n,X(:,3)));
X(:,4)=X(:,4)*(115600-63070)+63070;
X(:,5)=X(:,5)*(1110-990)+990;
X(:,6)=X(:,6)*(116-63.10)+63.10;
X(:,7)=X(:,7)*(820-700)+700;
X(:,8)=X(:,8)*(1680-1120)+1120;
X(:,9)=X(:,9)*(12045-9855)+9855;
Y=(2*pi*X(:,4).*(X(:,5)-X(:,7)))./(log(X(:,3)./X(:,2)).*(1+(2*X(:,8).*X(:,4))./(log(X(:,3)./X(:,2)).*X(:,2).^2.*X(:,9)) + X(:,4)./X(:,6)));

col=size(X,2)+1;

for i=2:9
    for j=i:9
        X(:,col)=X(:,i).*X(:,j);
        col=col+1;
        %X=cat(2,X,X(:,i).*X(:,j));
    end
end

lm=regress(Y,X);

residuals=abs(Y-(lm'*(X'))');
rss=sum(residuals.^2);
I am using matlab 2008.