Home > phiwave > @phiw_wavelet > private > pr_classdata.m

pr_classdata

PURPOSE ^

sets/gets class data for wavelet object

SYNOPSIS ^

function cdata = pr_classdata(fieldname, value)

DESCRIPTION ^

 sets/gets class data for wavelet object
 FORMAT cdata = pr_classdata(fieldname, value)

 phiw_wvavelet class data is implemented with a persistent variable
 - CLASSDATA.  This is a structure containing fields

 wtcentermethod   - centre method for wavelet transform.  Integer in the
                    range 0:3; see help for center.m for details

 Field values can be returned with the call
    phiw_wavelet('classdata') - which returns the whole structure
 or phiw_wavelet('classdata', fieldname) - which returns field data

 Field values can be set with the call
 phiw_wavelet('classdata', fieldname, value) OR
 phiw_wavelet('classdata', struct) where struct contains fields matching
 those in CLASSDATA

 The same functionality results from 
 classdata(obj, fieldname) etc.

 $Id: pr_classdata.m,v 1.2 2005/06/05 04:42:22 matthewbrett Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function cdata = pr_classdata(fieldname, value)
0002 % sets/gets class data for wavelet object
0003 % FORMAT cdata = pr_classdata(fieldname, value)
0004 %
0005 % phiw_wvavelet class data is implemented with a persistent variable
0006 % - CLASSDATA.  This is a structure containing fields
0007 %
0008 % wtcentermethod   - centre method for wavelet transform.  Integer in the
0009 %                    range 0:3; see help for center.m for details
0010 %
0011 % Field values can be returned with the call
0012 %    phiw_wavelet('classdata') - which returns the whole structure
0013 % or phiw_wavelet('classdata', fieldname) - which returns field data
0014 %
0015 % Field values can be set with the call
0016 % phiw_wavelet('classdata', fieldname, value) OR
0017 % phiw_wavelet('classdata', struct) where struct contains fields matching
0018 % those in CLASSDATA
0019 %
0020 % The same functionality results from
0021 % classdata(obj, fieldname) etc.
0022 %
0023 % $Id: pr_classdata.m,v 1.2 2005/06/05 04:42:22 matthewbrett Exp $
0024 
0025 persistent CLASSDATA
0026 if isempty(CLASSDATA)
0027   CLASSDATA = struct(...
0028       'wtcentermethod', 0);
0029 end
0030 
0031 if nargin < 1 % simple classdata call
0032   cdata = CLASSDATA;
0033   return
0034 end
0035 if nargin < 2 & ~isstruct(fieldname) % fieldname get call
0036   if isfield(CLASSDATA, fieldname) 
0037     cdata = getfield(CLASSDATA,fieldname);
0038   else 
0039     cdata = []; 
0040   end
0041   return
0042 end
0043 
0044 % some sort of set call
0045 if ~isstruct(fieldname) 
0046   fieldname = struct(struct(fieldname, value));
0047 end
0048 for field = fieldnames(fieldname)
0049   if isfield(CLASSDATA, field{1})
0050     CLASSDATA = setfield(CLASSDATA, field{1},...
0051                     getfield(fieldname, field{1}));
0052   end
0053 end
0054 cdata = CLASSDATA;

Generated on Wed 06-Jul-2005 18:07:21 by m2html © 2003