Mercurial > hg > ltpda
view m-toolbox/classes/@tsdata/getX.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
% GETX Get the property 'x'. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % DESCRIPTION: Get the property 'x'. % % CALL: val = obj.getX(); % val = obj.getX(idx); % val = obj.getX(1:10); % % INPUTS: obj - must be a single tsdata object. % idx - index of the data samples % % VERSION: $Id: getX.m,v 1.13 2011/07/05 06:32:40 mauro Exp $ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function x = getX(obj, idx) ly = length(obj.y); sx = size(obj.x); ts = 1/obj.fs; if sx(1) == 0 && sx(2) == 0 && ly>0 x = 0:ts:obj.nsecs-ts; %linspace(0, obj.nsecs-1/obj.fs, obj.nsecs*obj.fs); else x = obj.x; end % return always a column vector if size(x,1) == 1 x = x.'; end % add the toffset x = x + obj.toffset / 1000; % We can have rounding errors for strange sample rates and Nsecs if length(x) < ly while length(x) < ly x = [x; x(end)+ts]; end end if length(x) ~= ly x = x(1:length(obj.y)); end if nargin == 2 if strcmpi(idx, 'end') x = x(end); else x = x(idx); end end end