


CDATA constant data object class constructor.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: CDATA constant data object class constructor.
Create a constant data object.
Properties:
name - name of data object
vals - data values
tags - cell array: could be one descriptive tag per value
xunits - this is used to label the x-axis on plots.
yunits - this is used to label the y-axis on plots.
version - version of the constructor code
created - creation time of this fsdata object. Created by the function now
Possible constructors:
c = cdata() - creates a blank data object
c = cdata(pl) - creates a data object with the given
parameter list which contains 'N' and 'Val'
c = cdata(vals) - creates a data object with the given
data values.
c = cdata(N,v) - creates a data object with N samples all of
value, v.
HISTORY: 30-01-2007 Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


0001 function c = cdata(varargin) 0002 % CDATA constant data object class constructor. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: CDATA constant data object class constructor. 0007 % Create a constant data object. 0008 % 0009 % Properties: 0010 % name - name of data object 0011 % vals - data values 0012 % tags - cell array: could be one descriptive tag per value 0013 % xunits - this is used to label the x-axis on plots. 0014 % yunits - this is used to label the y-axis on plots. 0015 % version - version of the constructor code 0016 % created - creation time of this fsdata object. Created by the function now 0017 % 0018 % Possible constructors: 0019 % c = cdata() - creates a blank data object 0020 % c = cdata(pl) - creates a data object with the given 0021 % parameter list which contains 'N' and 'Val' 0022 % c = cdata(vals) - creates a data object with the given 0023 % data values. 0024 % c = cdata(N,v) - creates a data object with N samples all of 0025 % value, v. 0026 % 0027 % HISTORY: 30-01-2007 Hewitson 0028 % Creation 0029 % 0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0031 0032 ALGONAME = mfilename; 0033 VERSION = '$Id: cdata.html,v 1.2 2007/07/10 05:37:10 hewitson Exp $'; 0034 0035 if nargin == 0 % create default tsdata object 0036 c.name = 'None'; 0037 c.vals = []; 0038 c.tags = {}; 0039 c.xunits = 'N/A'; 0040 c.yunits = 'N/A'; 0041 c.version = VERSION; 0042 c.created = now; 0043 c = class(c, 'cdata'); 0044 elseif nargin == 1 % create cdata with given data 0045 if isa(varargin{1}, 'cdata') 0046 c = varargin{1}; 0047 elseif isstruct(varargin{1}) 0048 c = class(varargin{1}, 'cdata'); 0049 elseif isa(varargin{1}, 'plist') 0050 0051 % get possible parameters 0052 fcn = find(varargin{1}, 'fcn'); 0053 vals = find(varargin{1}, 'vals'); 0054 0055 % check which to use 0056 if ~isempty(fcn) 0057 % do function constructor 0058 vals = eval(fcn); 0059 elseif ~isempty(vals) 0060 % do vals constructor 0061 %- nothing to do here. 0062 else 0063 error('### unknown constructor method for cdata.'); 0064 end 0065 0066 c.name = fcn; 0067 c.vals = vals; 0068 c.tags = {}; 0069 c.xunits = 'N/A'; 0070 c.yunits = 'N/A'; 0071 c.version = VERSION; 0072 c.created = now; 0073 c = class(c, 'cdata'); 0074 0075 else 0076 c.name = 'Data'; 0077 c.vals = varargin{1}; 0078 c.tags = {}; 0079 c.xunits = 'N/A'; 0080 c.yunits = 'N/A'; 0081 c.version = VERSION; 0082 c.created = now; 0083 c = class(c, 'cdata'); 0084 end 0085 elseif nargin == 2 % N,v 0086 c.name = 'Constant'; 0087 c.vals = ones(varargin{1},1)*varargin{2}; 0088 c.tags = {}; 0089 c.xunits = 'N/A'; 0090 c.yunits = 'N/A'; 0091 c.version = VERSION; 0092 c.created = now; 0093 c = class(c, 'cdata'); 0094 else 0095 error('### Unknown number of constructor arguments.'); 0096 end 0097 0098 % check data 0099 % c = checkCdata(c); 0100 0101 0102 %-------------------------------------------------------------------------- 0103 % check vector has right dimensions 0104 function c = checkCdata(c) 0105 0106 x = c.vals; 0107 if size(x, 1) < size(x, 2) 0108 x = x.'; 0109 end 0110 0111 c = set(c, 'vals', x); 0112