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

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

% Compute mean value responses for each of the data objects in the response
% for the defined time interval

I = r.Time>=cd.StartTime & r.Time<=cd.EndTime;

data = r.Data.Amplitude;
cd.MeanValue = NaN*zeros([size(data,2) 1]);
for k=1:size(data,2)
   J = find(~isnan(data(:,k))&I);
   if ~isempty(J)
       cd.MeanValue(k) = mean(data(J,k));
       sigma = std(data(J,k));
       cd.Upperlimit(k) = cd.MeanValue(k)+sigma;
       cd.Lowerlimit(k) = cd.MeanValue(k)-sigma;
   else
       cd.MeanValue(k) = NaN;
       cd.Upperlimit(k) = NaN;
       cd.Lowerlimit(k) = NaN;
   end
end
 

%% TO DO: Use the timeseries object to compute the mean
