


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.38 2008/08/11 07:25:40 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.38 2008/08/11 07:25:40 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 end 0096 0097 %---------- Private Properties ---------- 0098 properties (GetAccess = protected, SetAccess = protected) 0099 end 0100 0101 %---------- Abstract Properties ---------- 0102 properties (Abstract = true, SetAccess = protected) 0103 end 0104 0105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0106 % Check property setting % 0107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0108 0109 methods 0110 function obj = set.t0(obj, val) 0111 if ~isa(val, 'time') || isempty(val) 0112 error('### The value for the property ''t0'' must be a time object'); 0113 end 0114 obj.t0 = val; 0115 end 0116 function obj = set.navs(obj, val) 0117 if ~isnumeric(val) || isempty(val) || length(val) < 0 || (~isnan(val) && rem(val,1)~=0) 0118 error('### The value for the property ''navs'' must be a positive integer'); 0119 end 0120 obj.navs = val; 0121 end 0122 function obj = set.fs(obj, val) 0123 if ~isempty(val) 0124 if ~isnumeric(val) || ~isreal(val) || val < 0 0125 error('### The value for the property ''fs'' must be a real positive number'); 0126 end 0127 end 0128 obj.fs = val; 0129 end 0130 function obj = set.enbw(obj, val) 0131 if ~isnumeric(val) || ~isreal(val) || any(val < 0) 0132 error('### The value for the property ''enbw'' must be a real positive number or a vector'); 0133 end 0134 if ~isempty(val) && ~isempty(obj.y) 0135 if length(val) ~=1 && (length(val) ~= length(obj.y)) 0136 error('### The ENBW can only be a single number, of a vector the same length as the y data.'); 0137 end 0138 end 0139 obj.enbw = val; 0140 end 0141 end 0142 0143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0144 % Constructor % 0145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0146 0147 methods 0148 function obj = fsdata(varargin) 0149 0150 %%% Call superclass 0151 obj = obj@data2D(varargin{:}); 0152 0153 %%%%%%%%%% Set dafault values %%%%%%%%%% 0154 %%% Exept for a struct as an input 0155 if ~(nargin == 1 && isstruct(varargin{1})) 0156 % set version 0157 obj.setVersion('$Id: fsdata.m,v 1.38 2008/08/11 07:25:40 hewitson Exp $'); 0158 end 0159 0160 if nargin == 0 0161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0162 %%%%%%%%%%%%%%%%%%%%%%%%%%%% no inputs %%%%%%%%%%%%%%%%%%%%%%%%%%%% 0163 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0164 0165 elseif nargin == 1 0166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0167 %%%%%%%%%%%%%%%%%%%%%%%%%%%% one input %%%%%%%%%%%%%%%%%%%%%%%%%%%% 0168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0169 0170 if isa(varargin{1}, 'fsdata') 0171 %%%%%%%%%% data = fsdata(fsdata-object) %%%%%%%%%% 0172 %----------- Copy fsdata Object 0173 obj = copy(varargin{1}, 1); 0174 0175 elseif isstruct(varargin{1}) 0176 %%%%%%%%%% data = fsdata(struct) %%%%%%%%%% 0177 %----------- struct 0178 obj.t0 = utils.helper.struct2obj(varargin{1}.t0, 'time'); 0179 obj.navs = varargin{1}.navs; 0180 obj.fs = varargin{1}.fs; 0181 obj.enbw = varargin{1}.enbw; 0182 0183 elseif isnumeric(varargin{1}) 0184 %%%%%%%%%% data = fsdata(y-vector) %%%%%%%%%% 0185 %----------- y vector 0186 obj.setY(varargin{1}); 0187 obj.setFs(1); 0188 obj.setX(fsdata.getFfromYFs(length(obj.y), obj.fs)); 0189 0190 else 0191 error('### Unknown single argument constructor.'); 0192 end 0193 elseif nargin == 2 0194 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0195 %%%%%%%%%%%%%%%%%%%%%%%%%%%% two input %%%%%%%%%%%%%%%%%%%%%%%%%%%% 0196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0197 0198 if numel(varargin{1}) > numel(varargin{2}) && numel(varargin{2}) == 1 0199 %%%%%%%%%% data = fsdata(y-vector, fs) %%%%%%%%%% 0200 % tsdata(y,fs) 0201 obj.setY(varargin{1}); 0202 obj.setFs(varargin{2}); 0203 obj.setX(fsdata.getFfromYFs(length(obj.y), obj.fs)); 0204 0205 elseif numel(varargin{1}) == numel(varargin{2}) 0206 %%%%%%%%%% data = fsdata(x-vector, y-vector) %%%%%%%%%% 0207 % tsdata(x,y) 0208 obj.setX(varargin{1}); 0209 obj.setY(varargin{2}); 0210 0211 else 0212 error('### Unknown two argument constructor.'); 0213 end 0214 elseif nargin == 3 0215 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0216 %%%%%%%%%%%%%%%%%%%%%%%%%%% three input %%%%%%%%%%%%%%%%%%%%%%%%%%% 0217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0218 0219 if numel(varargin{1}) == numel(varargin{2}) && numel(varargin{3}) == 1 0220 %%%%%%%%%% data = fsdata(x-vector, y-vector, fs) %%%%%%%%%% 0221 % tsdata(x,y,fs) 0222 obj.setXY(varargin{1}, varargin{2}); 0223 obj.setFs(varargin{3}); 0224 0225 else 0226 error('### Unknown three argument constructor.'); 0227 end 0228 else 0229 error('### Unknown number of constructor arguments.'); 0230 end 0231 end % End constructor 0232 end % End public methods 0233 0234 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0235 % Methods (Public) % 0236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0237 0238 methods 0239 % Setters 0240 varargout = setT0(varargin) 0241 varargout = setFs(varargin) 0242 varargout = setNavs(varargin) 0243 varargout = setEnbw(varargin) 0244 0245 % Other public methods 0246 varargout = copy(varargin) 0247 varargout = display(varargin); 0248 end % End public methods 0249 0250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0251 % Methods (protected) % 0252 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0253 0254 methods (Access = protected) 0255 end 0256 0257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0258 % Methods (private) % 0259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0260 0261 methods (Access = private) 0262 0263 end 0264 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0265 % Methods (static) % 0266 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0267 methods (Static) 0268 varargout = update_struct(varargin); 0269 0270 function out = VEROUT() 0271 out = '$Id: fsdata.m,v 1.38 2008/08/11 07:25:40 hewitson Exp $'; 0272 end 0273 0274 function ii = getInfo(varargin) 0275 ii = utils.helper.generic_getInfo(varargin{:}, 'fsdata'); 0276 end 0277 0278 function out = SETS() 0279 out = {'Default'}; 0280 end 0281 0282 function out = getDefaultPlist(set) 0283 switch set 0284 case 'Default' 0285 out = plist(); 0286 otherwise 0287 error('### Unknown set [%s]', set'); 0288 end 0289 end 0290 0291 end % End static methods 0292 0293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0294 % Methods (static, private) % 0295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0296 0297 methods (Static, Access = private) 0298 f = getFfromYFs(N,fs) 0299 end 0300 0301 end % End classdef 0302