Mercurial > hg > ltpda
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % GETX Get the property 'x'. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: Get the property 'x'. | |
5 % | |
6 % CALL: val = obj.getX(); | |
7 % val = obj.getX(idx); | |
8 % val = obj.getX(1:10); | |
9 % | |
10 % INPUTS: obj - must be a single tsdata object. | |
11 % idx - index of the data samples | |
12 % | |
13 % VERSION: $Id: getX.m,v 1.13 2011/07/05 06:32:40 mauro Exp $ | |
14 % | |
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
16 | |
17 function x = getX(obj, idx) | |
18 | |
19 ly = length(obj.y); | |
20 sx = size(obj.x); | |
21 ts = 1/obj.fs; | |
22 if sx(1) == 0 && sx(2) == 0 && ly>0 | |
23 x = 0:ts:obj.nsecs-ts; %linspace(0, obj.nsecs-1/obj.fs, obj.nsecs*obj.fs); | |
24 else | |
25 x = obj.x; | |
26 end | |
27 | |
28 % return always a column vector | |
29 if size(x,1) == 1 | |
30 x = x.'; | |
31 end | |
32 | |
33 % add the toffset | |
34 x = x + obj.toffset / 1000; | |
35 | |
36 % We can have rounding errors for strange sample rates and Nsecs | |
37 if length(x) < ly | |
38 while length(x) < ly | |
39 x = [x; x(end)+ts]; | |
40 end | |
41 end | |
42 | |
43 if length(x) ~= ly | |
44 x = x(1:length(obj.y)); | |
45 end | |
46 | |
47 if nargin == 2 | |
48 if strcmpi(idx, 'end') | |
49 x = x(end); | |
50 else | |
51 x = x(idx); | |
52 end | |
53 end | |
54 | |
55 end | |
56 |