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:41:55 $

%% Compute variance for each of the data objects in the response
%% for the defined freq interval

if isempty(cd.StartFreq)
    cd.StartFreq = r.Data.Frequency(1);
end
if isempty(cd.EndFreq)
    cd.EndFreq = r.Data.Frequency(end);
end

%% Find the frequency subinterval
I = find(r.Data.Frequency>=cd.StartFreq & r.Data.Frequency<=cd.EndFreq);
Lind = min(I);
Rind = max(I);

%% Compute char data from the periodogram data
for k=1:size(r.Data.Response,2)
    cd.Value(k) = mean(r.Data.Response(I,k));
    if strcmp(r.Data.Accumulate,'off')
        cd.Variance(k) = sum(r.Data.Response(:,k));
        cd.LVariance(k) = sum(r.Data.Response(1:Lind,k));
        cd.RVariance(k) = sum(r.Data.Response(1:Rind,k));
    else
        cd.LVariance(k) = r.Data.Response(Lind,k);
        cd.RVariance(k) = r.Data.Response(Rind,k);
        cd.Variance(k) = r.Data.Response(end,k);
    end
end
 
