function interp(h,ts,colind,T)
%interp
%
% Author(s): James G. Owen
% Revised:
% Copyright 1986-2004 The MathWorks, Inc.
% $Revision: 1.1.6.1 $ $Date: 2004/12/26 21:39:40 $


%% Recorder initialization
recorder = tsguis.recorder;

%% Remove blank rows
if strcmp(h.Rowremove,'on')
    if length(colind)>1 && strcmp(h.Rowor,'off')
       Irowexcl = all(isnan(ts.Data(:,colind))')';
       if strcmp(recorder.Recording,'on')
           T.addbuffer('%% Removing rows');
           T.addbuffer(['Irowexcl = all(isnan(', ts.Name, '.Data(:,[' ...
               num2str(colind) ']))'')'';'],ts);        
       end
    elseif length(colind)>1 && strcmp(h.Rowor,'on')
       Irowexcl = any(isnan(ts.Data(:,colind))')';
       if strcmp(recorder.Recording,'on')
           T.addbuffer('%% Removing rows');
           T.addbuffer(['Irowexcl = any(isnan(', ts.Name, '.Data(:,[' ...
               num2str(colind) ']))'')'';'],ts);        
       end      
    else
       Irowexcl = isnan(ts.Data(:,colind));
       if strcmp(recorder.Recording,'on')
           T.addbuffer('%% Removing rows');
           T.addbuffer(['Irowexcl = isnan(', ts.Name, '.Data(:,[' ...
               num2str(colind) ']));'],ts);        
       end        
    end
    ts.init(ts.Data(~Irowexcl,:),ts.Time(~Irowexcl));
    if strcmp(recorder.Recording,'on')
        T.addbuffer([ts.Name '.init(' ts.Name '.Data(~Irowexcl,:),' ...
            ts.Name '.Time(~Irowexcl));']); 
    end        
end

if strcmp(h.Interpolate,'on') 
    ts.resample(ts.Time);
    if strcmp(recorder.Recording,'on')
       T.addbuffer('%% Interpolating missing data');
       T.addbuffer([ts.name '.resample(' ts.Name '.Time);'],ts);
    end
end