Robert - create a logical matrix outside of the for loop and update it at each iteration according to whether there is a NaN in the column (for that row) or not. Something like
% screen the data over all pixels to select the ones with good data for
% regression analysis
[rows, cols]=size(Amp);
data=zeros(1, 9); % Amp, PET, P, AI, NDVI, ELE, SLOPE, FLOWACCU, SPI
dip=0;
isNanFree = logical(zeros(rows,cols));
for i=1:rows
for j=1:cols
% etc.
if isnan(camp)==0 && ...
isNanFree(i,j) = true;
% etc.
end
end
You can then simplify the isNanFree matrix to a column vector if needed.
As an aside, you should try to avoid using i and j as names for (indexing) variables as MATLAB also uses i and j to represent the imaginary number.
Also, you could modify your conditions to something like
~isnan(camp)
which is equivalent to yours but a little neater.