FSDATA frequency-series object class constructor. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: FSDATA frequency-series object class constructor. Create a frequency-series data object. Properties: name - name of frequency-series object f - frequency samples vector xx - xx samples vector enbw - equivalent noise bandwidth navs - number of averages fs - sample rate of data xunits - units to interpret the frequency samples (e.g., seconds) yunits - units to interpret the data samples (e.g., Volts) version - version of the constructor code created - creation time of this fsdata object in UTC format ‘yyyy-mm-dd HH:MM:SS’. Possible constructors: fsd = fsdata() - creates a blank frequency-series object fsd = fsdata(xx) - creates a frequency-series object with the given xx-data. Sample rate of the data is assumed to be 1Hz. fsd = fsdata(f,xx) - creates a frequency-series object with the given (f,xx)-data. The sample rate is then set as 2*f(end). fsd = fsdata(xx,fs) - creates a frequency-series object with the given xx-data and sample rate. The frequency vector is grown assuming the first xx sample corresponds to 0Hz and the last sample corresponds to the Nyquist frequency. fsd = fsdata(f,xx,fs) - creates a frequency-series object with the given f,xx-data and sample rate. HISTORY: 30-01-2007 Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function fsd = fsdata(varargin) 0002 % FSDATA frequency-series object class constructor. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: FSDATA frequency-series object class constructor. 0007 % Create a frequency-series data object. 0008 % 0009 % Properties: 0010 % name - name of frequency-series object 0011 % f - frequency samples vector 0012 % xx - xx samples vector 0013 % enbw - equivalent noise bandwidth 0014 % navs - number of averages 0015 % fs - sample rate of data 0016 % xunits - units to interpret the frequency samples (e.g., seconds) 0017 % yunits - units to interpret the data samples (e.g., Volts) 0018 % version - version of the constructor code 0019 % created - creation time of this fsdata object in UTC format ‘yyyy-mm-dd HH:MM:SS’. 0020 % 0021 % Possible constructors: 0022 % fsd = fsdata() - creates a blank frequency-series object 0023 % fsd = fsdata(xx) - creates a frequency-series object with the given 0024 % xx-data. Sample rate of the data is assumed to 0025 % be 1Hz. 0026 % fsd = fsdata(f,xx) - creates a frequency-series object with the given 0027 % (f,xx)-data. The sample rate is then set as 0028 % 2*f(end). 0029 % fsd = fsdata(xx,fs) - creates a frequency-series object with the given 0030 % xx-data and sample rate. The frequency 0031 % vector is grown assuming the first xx 0032 % sample corresponds to 0Hz and the last 0033 % sample corresponds to the Nyquist 0034 % frequency. 0035 % fsd = fsdata(f,xx,fs) - creates a frequency-series object with the given 0036 % f,xx-data and sample rate. 0037 % 0038 % HISTORY: 30-01-2007 Hewitson 0039 % Creation 0040 % 0041 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0042 0043 ALGONAME = mfilename; 0044 VERSION = '$Id: fsdata.html,v 1.1 2007/06/08 14:15:05 hewitson Exp $'; 0045 0046 0047 if nargin == 0 % create default fsdata object 0048 fsd.name = 'None'; 0049 fsd.f = []; 0050 fsd.xx = []; 0051 fsd.enbw = []; 0052 fsd.navs = []; 0053 fsd.fs = 0; 0054 fsd.xunits = 'Hz'; 0055 fsd.yunits = ''; 0056 fsd.version = VERSION; 0057 fsd.created = sprintf('%s', datestr(now)); 0058 fsd = class(fsd, 'fsdata'); 0059 elseif nargin == 1 % create fsdata with xx data 0060 if isa(varargin{1}, 'fsdata') 0061 fsd = varargin{1}; 0062 elseif isstruct(varargin{1}) 0063 fsd = class(varargin{1}, 'fsdata'); 0064 else 0065 fsd.name = 'None'; 0066 fsd.f = []; 0067 fsd.xx = varargin{1}; 0068 fsd.enbw = []; 0069 fsd.navs = []; 0070 fsd.fs = 0; 0071 fsd.xunits = 'Hz'; 0072 fsd.yunits = ''; 0073 fsd.version = VERSION; 0074 fsd.created = sprintf('%s', datestr(now)); 0075 fsd = class(fsd, 'fsdata'); 0076 end 0077 if size(fsd.xx,2) > size(fsd.xx,1) 0078 fsd.xx = [fsd.xx].'; 0079 end 0080 elseif nargin == 2 % f,xx data or xx,fs data 0081 if length(varargin{1}) == length(varargin{2}) % f, xx 0082 fsd.name = 'None'; 0083 fsd.f = varargin{1}; 0084 fsd.xx = varargin{2}; 0085 fsd.enbw = []; 0086 fsd.navs = []; 0087 fsd.fs = fsd.f(end)*2; 0088 fsd.xunits = 'Hz'; 0089 fsd.yunits = ''; 0090 fsd.version = VERSION; 0091 fsd.created = sprintf('%s', datestr(now)); 0092 fsd = class(fsd, 'fsdata'); 0093 if size(fsd.xx,2) > size(fsd.xx,1) 0094 fsd.xx = [fsd.xx].'; 0095 end 0096 fsd = reshapeF(fsd); 0097 else 0098 % check we have fs properly here 0099 if length(varargin{2}) > 1 0100 error(['### unknown constructor call. Either f and xx should be the' ... 0101 'same length, or fs should be a single value.']); 0102 end 0103 fsd.name = 'None'; 0104 fsd.f = []; 0105 fsd.xx = varargin{1}; 0106 fsd.enbw = []; 0107 fsd.navs = []; 0108 fsd.fs = varargin{2}; 0109 fsd.xunits = 'Hz'; 0110 fsd.yunits = ''; 0111 fsd.version = VERSION; 0112 fsd.created = sprintf('%s', datestr(now)); 0113 fsd = class(fsd, 'fsdata'); 0114 if size(fsd.xx,2) > size(fsd.xx,1) 0115 fsd.xx = [fsd.xx].'; 0116 end 0117 fsd = setFreq(fsd); 0118 end 0119 elseif nargin == 3 0120 fsd.name = 'None'; 0121 fsd.f = varargin{1}; 0122 fsd.xx = varargin{2}; 0123 fsd.enbw = []; 0124 fsd.navs = []; 0125 fsd.fs = varargin{3}; 0126 fsd.xunits = 'Hz'; 0127 fsd.yunits = ''; 0128 fsd.version = VERSION; 0129 fsd.created = sprintf('%s', datestr(now)); 0130 fsd = class(fsd, 'fsdata'); 0131 if size(fsd.xx,2) > size(fsd.xx,1) 0132 fsd.xx = [fsd.xx].'; 0133 end 0134 fsd = reshapeF(fsd); 0135 else 0136 error('### Unknown number of constructor arguments.'); 0137 end 0138