view m-toolbox/classes/@tsdata/collapseX.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line source

% COLLAPSEX Checks whether the x vector is evenly sampled and then removes it
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: Checks whether the x vector is evenly sampled and then removes
%              it after setting the t0 field.
%
% CALL:        obj = collapseX(obj)
%
% INPUT:       obj - tsdata object
%
% OUTPUT:      obj - tsdata object
%
% VERSION:     $Id: collapseX.m,v 1.9 2011/06/30 16:24:12 ingo Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = collapseX(varargin)

  obj = varargin{1};

  %%% decide whether we modify the pz-object, or create a new one.
  obj = copy(obj, nargout);

  if ~isempty(obj.x)
    [fs, t0, uneven] = tsdata.fitfs(obj.x);
    if uneven
      obj.fs = fs;
    else
      % adjust T0
      obj.toffset = obj.toffset + obj.x(1)*1e3;
      % adjust Nsecs
      obj.nsecs = length(obj.y)/obj.fs;
      % remove X samples
      obj.x  = [];
    end
  end

  varargout{1} = obj;
end