view m-toolbox/classes/@tsdata/collapseX.m @ 16:91f21a0aab35 database-connection-manager

Update utils.jquery * * * Update utils.jmysql.getsinfo
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
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