FSDATA frequency-series object class constructor. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: FSDATA frequency-series object class constructor. Create a frequency-series data object. SUPER CLASSES: data2D < ltpda_data < ltpda_nuo < ltpda_obj PROPERTIES: Inherit Properties (read only) version - cvs-version string xunits - units of the y-axis yunits - units of the y-axis x - data values of the x-axis y - data values of the y-axis Properties (read only) enbw - equivalent noise bandwidth navs - number of averages fs - sample rate of data t0 - time-stamp of the first data sample CONSTRUCTORS: fsd = fsdata() - creates a blank frequency-series object fsd = fsdata(y) - creates a frequency-series object with the given y-data. Sample rate of the data is assumed to be 1Hz. fsd = fsdata(f,y) - creates a frequency-series object with the given (x,y)-data. The sample rate is then set as 2*x(end). fsd = fsdata(y,fs) - creates a frequency-series object with the given y-data and sample rate. The frequency vector is grown assuming the first y sample corresponds to 0Hz and the last sample corresponds to the Nyquist frequency. fsd = fsdata(x,y,fs) - creates a frequency-series object with the given x,y-data and sample rate. FSDATA METHODS: Defined Abstract methods: char - returns one character string which represents the object copy - copies an object display - displays an object update_struct - updates a object structure to the current tbx-version Public methods: setT0 - set the property 't0' setFs - set the property 'fs' setNavs - set the property 'navs' setEnbw - set the property 'enbw' M-FILE INFO: The following call returns an minfo object that contains information about the fsdata constructor: >> info = fsdata.getInfo or >> info = fsdata.getInfo('fsdata') You can get information about class methods by calling: >> info = fsdata.getInfo(method) e.g. >> info = fsdata.getInfo('eq') You can also restrict the sets of parameters contained in the minfo object by calling: >> info = fsdata.getInfo(method, set) e.g. >> info = fsdata.getInfo('fsdata', 'Default') VERSION: $Id: fsdata.m,v 1.39 2008/09/03 16:32:18 hewitson Exp $ HISTORY: 30-01-2007 Hewitson Creation SEE ALSO: tsdata, fsdata, xydata, cdata, data2D, data3D, xyzdata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % FSDATA frequency-series object class constructor. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: FSDATA frequency-series object class constructor. 0005 % Create a frequency-series data object. 0006 % 0007 % SUPER CLASSES: data2D < ltpda_data < ltpda_nuo < ltpda_obj 0008 % 0009 % PROPERTIES: 0010 % 0011 % Inherit Properties (read only) 0012 % version - cvs-version string 0013 % xunits - units of the y-axis 0014 % yunits - units of the y-axis 0015 % x - data values of the x-axis 0016 % y - data values of the y-axis 0017 % 0018 % Properties (read only) 0019 % enbw - equivalent noise bandwidth 0020 % navs - number of averages 0021 % fs - sample rate of data 0022 % t0 - time-stamp of the first data sample 0023 % 0024 % CONSTRUCTORS: 0025 % 0026 % fsd = fsdata() - creates a blank frequency-series object 0027 % fsd = fsdata(y) - creates a frequency-series object with the given 0028 % y-data. Sample rate of the data is assumed to 0029 % be 1Hz. 0030 % fsd = fsdata(f,y) - creates a frequency-series object with the given 0031 % (x,y)-data. The sample rate is then set as 0032 % 2*x(end). 0033 % fsd = fsdata(y,fs) - creates a frequency-series object with the given 0034 % y-data and sample rate. The frequency 0035 % vector is grown assuming the first y 0036 % sample corresponds to 0Hz and the last 0037 % sample corresponds to the Nyquist 0038 % frequency. 0039 % fsd = fsdata(x,y,fs) - creates a frequency-series object with the given 0040 % x,y-data and sample rate. 0041 % 0042 % FSDATA METHODS: 0043 % 0044 % Defined Abstract methods: 0045 % char - returns one character string which represents the object 0046 % copy - copies an object 0047 % display - displays an object 0048 % update_struct - updates a object structure to the current tbx-version 0049 % 0050 % Public methods: 0051 % setT0 - set the property 't0' 0052 % setFs - set the property 'fs' 0053 % setNavs - set the property 'navs' 0054 % setEnbw - set the property 'enbw' 0055 % 0056 % M-FILE INFO: The following call returns an minfo object that contains 0057 % information about the fsdata constructor: 0058 % >> info = fsdata.getInfo 0059 % or >> info = fsdata.getInfo('fsdata') 0060 % 0061 % You can get information about class methods by calling: 0062 % >> info = fsdata.getInfo(method) 0063 % e.g. >> info = fsdata.getInfo('eq') 0064 % 0065 % You can also restrict the sets of parameters contained in 0066 % the minfo object by calling: 0067 % >> info = fsdata.getInfo(method, set) 0068 % e.g. >> info = fsdata.getInfo('fsdata', 'Default') 0069 % 0070 % VERSION: $Id: fsdata.m,v 1.39 2008/09/03 16:32:18 hewitson Exp $ 0071 % 0072 % HISTORY: 30-01-2007 Hewitson 0073 % Creation 0074 % 0075 % SEE ALSO: tsdata, fsdata, xydata, cdata, data2D, data3D, xyzdata 0076 % 0077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0078 0079 classdef fsdata < data2D 0080 0081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0082 % Property definition % 0083 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0084 0085 %---------- Public (read/write) Properties ---------- 0086 properties 0087 end 0088 0089 %---------- Protected read-only Properties ---------- 0090 properties (SetAccess = protected) 0091 t0 = time(0); 0092 navs = NaN; 0093 fs = NaN; 0094 enbw = NaN; 0095 version = '$Id: fsdata.m,v 1.39 2008/09/03 16:32:18 hewitson Exp $'; 0096 end 0097 0098 %---------- Private Properties ---------- 0099 properties (GetAccess = protected, SetAccess = protected) 0100 end 0101 0102 %---------- Abstract Properties ---------- 0103 properties (Abstract = true, SetAccess = protected) 0104 end 0105 0106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0107 % Check property setting % 0108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0109 0110 methods 0111 function obj = set.t0(obj, val) 0112 if ~isa(val, 'time') || isempty(val) 0113 error('### The value for the property ''t0'' must be a time object'); 0114 end 0115 obj.t0 = val; 0116 end 0117 function obj = set.navs(obj, val) 0118 if ~isnumeric(val) || isempty(val) || length(val) < 0 || (~isnan(val) && rem(val,1)~=0) 0119 error('### The value for the property ''navs'' must be a positive integer'); 0120 end 0121 obj.navs = val; 0122 end 0123 function obj = set.fs(obj, val) 0124 if ~isempty(val) 0125 if ~isnumeric(val) || ~isreal(val) || val < 0 0126 error('### The value for the property ''fs'' must be a real positive number'); 0127 end 0128 end 0129 obj.fs = val; 0130 end 0131 function obj = set.enbw(obj, val) 0132 if ~isnumeric(val) || ~isreal(val) || any(val < 0) 0133 error('### The value for the property ''enbw'' must be a real positive number or a vector'); 0134 end 0135 if ~isempty(val) && ~isempty(obj.y) 0136 if length(val) ~=1 && (length(val) ~= length(obj.y)) 0137 error('### The ENBW can only be a single number, of a vector the same length as the y data.'); 0138 end 0139 end 0140 obj.enbw = val; 0141 end 0142 end 0143 0144 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0145 % Constructor % 0146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0147 0148 methods 0149 function obj = fsdata(varargin) 0150 0151 %%% Call superclass 0152 obj = obj@data2D(varargin{:}); 0153 0154 %%%%%%%%%% Set dafault values %%%%%%%%%% 0155 0156 if nargin == 0 0157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0158 %%%%%%%%%%%%%%%%%%%%%%%%%%%% no inputs %%%%%%%%%%%%%%%%%%%%%%%%%%%% 0159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0160 0161 elseif nargin == 1 0162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0163 %%%%%%%%%%%%%%%%%%%%%%%%%%%% one input %%%%%%%%%%%%%%%%%%%%%%%%%%%% 0164 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0165 0166 if isa(varargin{1}, 'fsdata') 0167 %%%%%%%%%% data = fsdata(fsdata-object) %%%%%%%%%% 0168 %----------- Copy fsdata Object 0169 obj = copy(varargin{1}, 1); 0170 0171 elseif isstruct(varargin{1}) 0172 %%%%%%%%%% data = fsdata(struct) %%%%%%%%%% 0173 %----------- struct 0174 obj.t0 = utils.helper.struct2obj(varargin{1}.t0, 'time'); 0175 obj.navs = varargin{1}.navs; 0176 obj.fs = varargin{1}.fs; 0177 obj.enbw = varargin{1}.enbw; 0178 obj.version = varargin{1}.version; 0179 0180 elseif isnumeric(varargin{1}) 0181 %%%%%%%%%% data = fsdata(y-vector) %%%%%%%%%% 0182 %----------- y vector 0183 obj.setY(varargin{1}); 0184 obj.setFs(1); 0185 obj.setX(fsdata.getFfromYFs(length(obj.y), obj.fs)); 0186 0187 else 0188 error('### Unknown single argument constructor.'); 0189 end 0190 elseif nargin == 2 0191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0192 %%%%%%%%%%%%%%%%%%%%%%%%%%%% two input %%%%%%%%%%%%%%%%%%%%%%%%%%%% 0193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0194 0195 if numel(varargin{1}) > numel(varargin{2}) && numel(varargin{2}) == 1 0196 %%%%%%%%%% data = fsdata(y-vector, fs) %%%%%%%%%% 0197 % tsdata(y,fs) 0198 obj.setY(varargin{1}); 0199 obj.setFs(varargin{2}); 0200 obj.setX(fsdata.getFfromYFs(length(obj.y), obj.fs)); 0201 0202 elseif numel(varargin{1}) == numel(varargin{2}) 0203 %%%%%%%%%% data = fsdata(x-vector, y-vector) %%%%%%%%%% 0204 % tsdata(x,y) 0205 obj.setX(varargin{1}); 0206 obj.setY(varargin{2}); 0207 0208 else 0209 error('### Unknown two argument constructor.'); 0210 end 0211 elseif nargin == 3 0212 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0213 %%%%%%%%%%%%%%%%%%%%%%%%%%% three input %%%%%%%%%%%%%%%%%%%%%%%%%%% 0214 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0215 0216 if numel(varargin{1}) == numel(varargin{2}) && numel(varargin{3}) == 1 0217 %%%%%%%%%% data = fsdata(x-vector, y-vector, fs) %%%%%%%%%% 0218 % tsdata(x,y,fs) 0219 obj.setXY(varargin{1}, varargin{2}); 0220 obj.setFs(varargin{3}); 0221 0222 else 0223 error('### Unknown three argument constructor.'); 0224 end 0225 else 0226 error('### Unknown number of constructor arguments.'); 0227 end 0228 end % End constructor 0229 end % End public methods 0230 0231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0232 % Methods (Public) % 0233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0234 0235 methods 0236 % Setters 0237 varargout = setT0(varargin) 0238 varargout = setFs(varargin) 0239 varargout = setNavs(varargin) 0240 varargout = setEnbw(varargin) 0241 0242 % Other public methods 0243 varargout = copy(varargin) 0244 varargout = display(varargin); 0245 end % End public methods 0246 0247 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0248 % Methods (protected) % 0249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0250 0251 methods (Access = protected) 0252 end 0253 0254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0255 % Methods (private) % 0256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0257 0258 methods (Access = private) 0259 0260 end 0261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0262 % Methods (static) % 0263 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0264 methods (Static) 0265 varargout = update_struct(varargin); 0266 0267 function out = VEROUT() 0268 out = '$Id: fsdata.m,v 1.39 2008/09/03 16:32:18 hewitson Exp $'; 0269 end 0270 0271 function ii = getInfo(varargin) 0272 ii = utils.helper.generic_getInfo(varargin{:}, 'fsdata'); 0273 end 0274 0275 function out = SETS() 0276 out = {'Default'}; 0277 end 0278 0279 function out = getDefaultPlist(set) 0280 switch set 0281 case 'Default' 0282 out = plist(); 0283 otherwise 0284 error('### Unknown set [%s]', set'); 0285 end 0286 end 0287 0288 end % End static methods 0289 0290 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0291 % Methods (static, private) % 0292 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0293 0294 methods (Static, Access = private) 0295 f = getFfromYFs(N,fs) 0296 end 0297 0298 end % End classdef 0299