


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)
version - current version of the constructor
created - current date and time as an number
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 % version - current version of the constructor 0016 % created - current date and time as an number 0017 % 0018 % Possible constructors: 0019 % xy = xydata() - creates a blank time-series object 0020 % xy = xydata(y) - creates a time-series object with the given 0021 % x-data. 0022 % xy = xydata(x,y) - creates a time-series object with the given 0023 % (x,y)-data. 0024 % 0025 % HISTORY: 30-01-2007 Hewitson 0026 % Creation 0027 % 0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0029 0030 ALGONAME = mfilename; 0031 VERSION = '$Id: xydata.m,v 1.5 2007/06/18 11:00:24 ingo Exp $'; 0032 0033 if nargin == 0 % create default xydata object 0034 xy.name = 'None'; 0035 xy.x = []; 0036 xy.y = []; 0037 xy.xunits = ''; 0038 xy.yunits = ''; 0039 xy.version = VERSION; 0040 xy.created = now; 0041 xy = class(xy, 'xydata'); 0042 elseif nargin == 1 % create xydata with y data 0043 if isa(varargin{1}, 'xydata') 0044 xy = varargin{1}; 0045 elseif isstruct(varargin{1}) 0046 xy = class(varargin{1}, 'xydata'); 0047 else 0048 xy.name = 'None'; 0049 xy.x = 1:length(varargin{1}); 0050 xy.y = varargin{1}; 0051 xy.xunits = ''; 0052 xy.yunits = ''; 0053 xy.version = VERSION; 0054 xy.created = now; 0055 end 0056 xy = class(xy, 'xydata'); 0057 if size(xy.y,2) > size(xy.y,1) 0058 xy.y = [xy.y].'; 0059 end 0060 xy.x = reshape(xy.x, size(xy.y)); 0061 elseif nargin == 2 % x,y data 0062 xy.name = 'None'; 0063 xy.x = varargin{1}; 0064 xy.y = varargin{2}; 0065 xy.xunits = ''; 0066 xy.yunits = ''; 0067 xy.version = VERSION; 0068 xy.created = now; 0069 xy = class(xy, 'xydata'); 0070 if size(xy.y,2) > size(xy.y,1) 0071 xy.y = [xy.y].'; 0072 end 0073 xy.x = reshape(xy.x, size(xy.y)); 0074 else 0075 error('### Unknown number of constructor arguments.'); 0076 end 0077