function update(cd,r)
%UPDATE  Data update method for @regLineData class.

%  Author(s):  
%  Copyright 1986-2002 The MathWorks, Inc.
%  $Revision: 1.1.6.1 $  $Date: 2004/12/26 21:39:58 $

% Compute regression lines
for k=1:size(r.Data.XData,2)
    for j=1:size(r.Data.YData,2)
        I = find(~any(isnan([r.Data.XData(:,k) r.Data.YData(:,j)])')');
        if ~isempty(I)
            meanX = mean(r.Data.XData(I,k));
            meanY = mean(r.Data.YData(I,j));
            if norm(r.Data.XData(I,k)-meanX)>eps
                cd.Slopes(k,j) = (r.Data.YData(I,j)-meanY)'* ...
                    (r.Data.XData(I,k)-meanX)/norm(r.Data.XData(I,k)-meanX)^2;
                cd.Biases(k,j) = meanY-cd.Slopes(k,j)*meanX;
            else
                cd.Slopes(k,j) = NaN;
                cd.Biases(k,j) = NaN;
            end
        else
            cd.Slopes(k,j) = NaN;
            cd.Biases(k,j) = NaN;
        end    
    end
end
