Home > classes > @cdata > cdata.m

cdata

PURPOSE ^

CDATA constant data object class constructor.

SYNOPSIS ^

function c = cdata(varargin)

DESCRIPTION ^

 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 in UTC format
                 yyyy-mm-dd HH:MM:SS
 
     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

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

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 in UTC format
0017 %                 yyyy-mm-dd HH:MM:SS
0018 %
0019 %     Possible constructors:
0020 %       c = cdata()      - creates a blank data object
0021 %       c = cdata(pl)    - creates a data object with the given
0022 %                          parameter list which contains 'N' and 'Val'
0023 %       c = cdata(vals)  - creates a data object with the given
0024 %                          data values.
0025 %       c = cdata(N,v)   - creates a data object with N samples all of
0026 %                          value, v.
0027 %
0028 % HISTORY: 30-01-2007 Hewitson
0029 %             Creation
0030 %
0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0032 
0033 ALGONAME = mfilename;
0034 VERSION  = '$Id: cdata.html,v 1.1 2007/06/08 14:15:05 hewitson Exp $';
0035 
0036 if nargin == 0                  % create default tsdata object
0037   c.name    = 'None';
0038   c.vals    = [];
0039   c.tags    = {};
0040   c.xunits  = 'N/A';
0041   c.yunits  = 'N/A';
0042   c.version = VERSION;
0043   c.created   = sprintf('%s', datestr(now));
0044   c = class(c, 'cdata');
0045 elseif nargin == 1                % create cdata with given data
0046   if isa(varargin{1}, 'cdata')
0047     c = varargin{1};
0048   elseif isstruct(varargin{1})
0049     c = class(varargin{1}, 'cdata');
0050   elseif isa(varargin{1}, 'plist')
0051 
0052     % get possible parameters
0053     fcn   = find(varargin{1}, 'fcn');
0054     vals = find(varargin{1}, 'vals');
0055 
0056     % check which to use
0057     if ~isempty(fcn)
0058       % do function constructor
0059       vals = eval(fcn);
0060     elseif ~isempty(vals)
0061       % do vals constructor
0062       %- nothing to do here.
0063     else
0064       error('### unknown constructor method for cdata.');
0065     end
0066 
0067     c.name    = fcn;
0068     c.vals    = vals;
0069     c.tags    = {};
0070     c.xunits  = 'N/A';
0071     c.yunits  = 'N/A';
0072     c.version = VERSION;
0073     c.created   = sprintf('%s', datestr(now));
0074     c = class(c, 'cdata');
0075 
0076   else
0077     c.name    = 'Data';
0078     c.vals    = varargin{1};
0079     c.tags    = {};
0080     c.xunits  = 'N/A';
0081     c.yunits  = 'N/A';
0082     c.version = VERSION;
0083     c.created   = sprintf('%s', datestr(now));
0084     c = class(c, 'cdata');
0085   end
0086 elseif nargin == 2              % N,v
0087     c.name    = 'Constant';
0088     c.vals    = ones(varargin{1},1)*varargin{2};
0089     c.tags    = {};
0090     c.xunits  = 'N/A';
0091     c.yunits  = 'N/A';
0092     c.version = VERSION;
0093     c.created   = sprintf('%s', datestr(now));
0094     c = class(c, 'cdata');
0095 else
0096   error('### Unknown number of constructor arguments.');
0097 end
0098 
0099 % check data
0100 % c = checkCdata(c);
0101 
0102 
0103 %--------------------------------------------------------------------------
0104 % check vector has right dimensions
0105 function c = checkCdata(c)
0106 
0107 x = c.vals;
0108 if size(x, 1) < size(x, 2)
0109   x = x.';
0110 end
0111 
0112 c = set(c, 'vals', x);
0113

Generated on Fri 08-Jun-2007 16:09:11 by m2html © 2003