comparison m-toolbox/classes/@tsdata/setFs.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 % SETFS Set the property 'fs'.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: Set the property 'fs'.
5 %
6 % CALL: obj.setFs(12);
7 % obj = obj.setFs(12); create copy of the object
8 %
9 % INPUTS: obj - must be a single data2D object.
10 %
11 % VERSION: $Id: setFs.m,v 1.5 2011/09/29 12:09:24 ingo Exp $
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function varargout = setFs(varargin)
16
17 obj = varargin{1};
18 val = varargin{2};
19
20 % decide whether we modify the pz-object, or create a new one.
21 obj = copy(obj, nargout);
22
23 % set 'fs'
24 obj.fs = val;
25
26 % Now we can set nsecs
27 if ~isempty(obj.x)
28 % Then we have unevenly sampled data and the data duration
29 % is taken as x(end) - x(1);
30 obj.setNsecs(obj.x(end)-obj.x(1) + 1/obj.fs);
31 else
32 if ~isempty(obj.y)
33 % Then the data is evenly sampled and the
34 % duration of the data is easily computed.
35 Ndata = length(obj.y);
36 obj.setNsecs(Ndata / obj.fs);
37 end
38 end
39
40 varargout{1} = obj;
41 end
42
43