function histresp(src,r,hplot)
%FREQRESP  Updates @histdata objects 
%  Author(s):  
%  Copyright 1986-2002 The MathWorks, Inc.
%  $Revision: 1.1.6.1 $ $Date: 2004/12/26 21:43:33 $

%% Get new data from the @timeseries object if necessary converting them to
%% uniform
%[data,Ts] = tsToRegular(src);
data = src.Timeseries.Data;

%% Look for visible+cleared responses in response array
if isempty(r.Data.YData) && strcmp(r.View.Visible,'on')
      if size(data,1)>1
          [N,bins] = hist(data,hplot.Bins);
      elseif size(data,1)==1
          [N,bins] = hist([data;NaN*ones(size(data))],hplot.Bins); 
      else
          N = zeros([length(bins) size(data,2)]);
      end
      N = reshape(N,[length(bins) size(data,2)]);
      bins = bins(:);
      % Nan out masked columns
      if ~isempty(src.Mask) && length(src.Mask)==size(N,2)
          N(:,src.Mask) = NaN*ones([size(N,1) sum(src.Mask)]);
      end
      % Update the data with the power spec
      if length(bins)>=2
          set(r.Data,'YData',N,'XData',bins,'Focus',[1.5*bins(1)-0.5*bins(2) ...
              1.5*bins(end)-0.5*bins(end-1)]);
      elseif length(bins)==1
          set(r.Data,'YData',N,'XData',bins)
      end
end

%% The response name should match the time series name
r.Name = src.Timeseries.Name;
