XYDATA X-Y data object class constructor. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: XYDATA X-Y data object class constructor. Create an X-Y data object. Properties: name - name of time-series object x - x samples vector y - y samples vector xunits - units to interpret the time samples (e.g., seconds) yunits - units to interpret the data samples (e.g., Volts) Possible constructors: xy = xydata() - creates a blank time-series object xy = xydata(y) - creates a time-series object with the given x-data. xy = xydata(x,y) - creates a time-series object with the given (x,y)-data. HISTORY: 30-01-2007 Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function xy = xydata(varargin) 0002 % XYDATA X-Y data object class constructor. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: XYDATA X-Y data object class constructor. 0007 % Create an X-Y data object. 0008 % 0009 % Properties: 0010 % name - name of time-series object 0011 % x - x samples vector 0012 % y - y samples vector 0013 % xunits - units to interpret the time samples (e.g., seconds) 0014 % yunits - units to interpret the data samples (e.g., Volts) 0015 % 0016 % Possible constructors: 0017 % xy = xydata() - creates a blank time-series object 0018 % xy = xydata(y) - creates a time-series object with the given 0019 % x-data. 0020 % xy = xydata(x,y) - creates a time-series object with the given 0021 % (x,y)-data. 0022 % 0023 % HISTORY: 30-01-2007 Hewitson 0024 % Creation 0025 % 0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0027 0028 ALGONAME = mfilename; 0029 VERSION = '$Id: xydata.html,v 1.1 2007/06/08 14:15:09 hewitson Exp $'; 0030 0031 if nargin == 0 % create default xydata object 0032 xy.name = 'None'; 0033 xy.x = []; 0034 xy.y = []; 0035 xy.xunits = ''; 0036 xy.yunits = ''; 0037 xy.version = VERSION; 0038 xy.created = sprintf('%s', datestr(now)); 0039 xy = class(xy, 'xydata'); 0040 elseif nargin == 1 % create xydata with y data 0041 if isa(varargin{1}, 'xydata') 0042 xy = varargin{1}; 0043 elseif isstruct(varargin{1}) 0044 xy = class(varargin{1}, 'xydata'); 0045 else 0046 xy.name = 'None'; 0047 xy.x = 1:length(varargin{1}); 0048 xy.y = varargin{1}; 0049 xy.xunits = ''; 0050 xy.yunits = ''; 0051 xy.version = VERSION; 0052 xy.created = sprintf('%s', datestr(now)); 0053 end 0054 xy = class(xy, 'xydata'); 0055 if size(xy.y,2) > size(xy.y,1) 0056 xy.y = [xy.y].'; 0057 end 0058 xy.x = reshape(xy.x, size(xy.y)); 0059 elseif nargin == 2 % x,y data 0060 xy.name = 'None'; 0061 xy.x = varargin{1}; 0062 xy.y = varargin{2}; 0063 xy.xunits = ''; 0064 xy.yunits = ''; 0065 xy.version = VERSION; 0066 xy.created = sprintf('%s', datestr(now)); 0067 xy = class(xy, 'xydata'); 0068 if size(xy.y,2) > size(xy.y,1) 0069 xy.y = [xy.y].'; 0070 end 0071 xy.x = reshape(xy.x, size(xy.y)); 0072 else 0073 error('### Unknown number of constructor arguments.'); 0074 end 0075