Home > classes > @specwin > specwin.m

specwin

PURPOSE ^

% SPECWIN spectral window object class constructor.

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

  % SPECWIN spectral window object class constructor.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: SPECWIN spectral window object class constructor.
              Create a spectral window from libSpecWin.

 SUPER CLASSES: ltpda_nuo < ltpda_obj

 PROPERTIES:

     Inherit Properties (read only)
       version  - cvs-version string.

     Protected Properties (read only)
       type     - name of window object
       alpha    - alpha parameter for various window functions
       psll     - peak sidelobe level
       rov      - recommended overlap
       nenbw    - normalised equivalent noise bandwidth
       w3db     - 3 dB bandwidth in bins
       flatness - window flatness
       ws       - sum of window values
       ws2      - sum of squares of window values
       win      - window samples (column vector)

  CONSTRUCTOR:

       w = specwin()
           creates an empty object

       w = specwin(w)
           copies a specwin object

       w = specwin('name', N)
           creates a specwin object of a particular type and length.
           (see below for supported types.)

       w = specwin('Kaiser', N, psll)
           create a specwin Kaiser window with the prescribed psll.

 'name' should be one of the following standard windows:

    Rectangular, Welch, Bartlett, Hanning, Hamming,
    Nuttall3, Nuttall4, Nuttall3a, Nuttall3b, Nuttall4a
    Nuttall4b, Nuttall4c, BH92, SFT3F, SFT3M, FTNI, SFT4F, SFT5F
    SFT4M, FTHP, HFT70, FTSRS, SFT5M, HFT90D, HFT95, HFT116D
    HFT144D, HFT169D, HFT196D, HFT223D, HFT248D

 M-FILE INFO:  The following call returns an minfo object that contains
               information about the specwin constructor:
                    >> info = specwin.getInfo
               or   >> info = specwin.getInfo('specwin')

               You can get information about class methods by calling:
                    >> info = specwin.getInfo(method)
               e.g. >> info = specwin.getInfo('eq')

               You can also restrict the sets of parameters contained in
               the minfo object by calling:
                    >> info = specwin.getInfo(method, set)
               e.g. >> info = specwin.getInfo('specwin', 'Default')

 VERSION:     $Id: specwin.m,v 1.52 2008/08/11 08:40:21 hewitson Exp $

 HISTORY:     30-01-07 M Hewitson
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 %  % SPECWIN spectral window object class constructor.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: SPECWIN spectral window object class constructor.
0005 %              Create a spectral window from libSpecWin.
0006 %
0007 % SUPER CLASSES: ltpda_nuo < ltpda_obj
0008 %
0009 % PROPERTIES:
0010 %
0011 %     Inherit Properties (read only)
0012 %       version  - cvs-version string.
0013 %
0014 %     Protected Properties (read only)
0015 %       type     - name of window object
0016 %       alpha    - alpha parameter for various window functions
0017 %       psll     - peak sidelobe level
0018 %       rov      - recommended overlap
0019 %       nenbw    - normalised equivalent noise bandwidth
0020 %       w3db     - 3 dB bandwidth in bins
0021 %       flatness - window flatness
0022 %       ws       - sum of window values
0023 %       ws2      - sum of squares of window values
0024 %       win      - window samples (column vector)
0025 %
0026 %  CONSTRUCTOR:
0027 %
0028 %       w = specwin()
0029 %           creates an empty object
0030 %
0031 %       w = specwin(w)
0032 %           copies a specwin object
0033 %
0034 %       w = specwin('name', N)
0035 %           creates a specwin object of a particular type and length.
0036 %           (see below for supported types.)
0037 %
0038 %       w = specwin('Kaiser', N, psll)
0039 %           create a specwin Kaiser window with the prescribed psll.
0040 %
0041 % 'name' should be one of the following standard windows:
0042 %
0043 %    Rectangular, Welch, Bartlett, Hanning, Hamming,
0044 %    Nuttall3, Nuttall4, Nuttall3a, Nuttall3b, Nuttall4a
0045 %    Nuttall4b, Nuttall4c, BH92, SFT3F, SFT3M, FTNI, SFT4F, SFT5F
0046 %    SFT4M, FTHP, HFT70, FTSRS, SFT5M, HFT90D, HFT95, HFT116D
0047 %    HFT144D, HFT169D, HFT196D, HFT223D, HFT248D
0048 %
0049 % M-FILE INFO:  The following call returns an minfo object that contains
0050 %               information about the specwin constructor:
0051 %                    >> info = specwin.getInfo
0052 %               or   >> info = specwin.getInfo('specwin')
0053 %
0054 %               You can get information about class methods by calling:
0055 %                    >> info = specwin.getInfo(method)
0056 %               e.g. >> info = specwin.getInfo('eq')
0057 %
0058 %               You can also restrict the sets of parameters contained in
0059 %               the minfo object by calling:
0060 %                    >> info = specwin.getInfo(method, set)
0061 %               e.g. >> info = specwin.getInfo('specwin', 'Default')
0062 %
0063 % VERSION:     $Id: specwin.m,v 1.52 2008/08/11 08:40:21 hewitson Exp $
0064 %
0065 % HISTORY:     30-01-07 M Hewitson
0066 %                 Creation
0067 %
0068 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0069 
0070 %       w = specwin('Flattop', N, psll) - create a specwin Flattop window
0071 %                                         with the prescribed psll.
0072 
0073 classdef specwin < ltpda_nuo
0074 
0075   %------------------------------------------------
0076   %---------- Private read-only Properties --------
0077   %------------------------------------------------
0078   properties (SetAccess = private)
0079     type     = '';
0080     alpha    = [];
0081     psll     = [];
0082     rov      = [];
0083     nenbw    = [];
0084     w3db     = [];
0085     flatness = [];
0086     ws       = [];
0087     ws2      = [];
0088     win      = [];
0089   end
0090 
0091   %------------------------------------------------
0092   %-------- Declaration of public methods --------
0093   %------------------------------------------------
0094   methods
0095 
0096     %------------------------------------------------
0097     %-------- Property rules                 --------
0098     %------------------------------------------------
0099     function obj = set.type(obj,val)
0100 %       if ~ischar(val)
0101 %         error('### The <type> property should be a character array.');
0102 %       end
0103       obj.type = val;
0104     end
0105     function obj = set.alpha(obj,val)
0106 %       if ~isnumeric(val) || numel(val) > 1 || val < 0 || ~isreal(val)
0107 %         error('### The <alpha> property should be a positive real number.');
0108 %       end
0109       obj.alpha = val;
0110     end
0111     function obj = set.psll(obj,val)
0112 %       if ~isnumeric(val) || numel(val) > 1 || ~isreal(val)
0113 %         error('### The <psll> property should be a real number.');
0114 %       end
0115       obj.psll = val;
0116     end
0117     function obj = set.rov(obj,val)
0118 %       if ~isnumeric(val) || numel(val) > 1 || val < 0 || ~isreal(val)
0119 %         error('### The <rov> property should be a positive real number.');
0120 %       end
0121       obj.rov = val;
0122     end
0123     function obj = set.nenbw(obj,val)
0124 %       if ~isnumeric(val) || numel(val) > 1 || val < 0 || ~isreal(val)
0125 %         error('### The <nenbw> property should be a positive real number.');
0126 %       end
0127       obj.nenbw = val;
0128     end
0129     function obj = set.w3db(obj,val)
0130 %       if ~isnumeric(val) || numel(val) > 1 || val < 0 || ~isreal(val)
0131 %         error('### The <w3db> property should be a positive real number.');
0132 %       end
0133       obj.w3db = val;
0134     end
0135     function obj = set.flatness(obj,val)
0136 %       if ~isnumeric(val) || numel(val) > 1|| ~isreal(val)
0137 %         error('### The <flatness> property should be a real number.');
0138 %       end
0139       obj.flatness = val;
0140     end
0141     function obj = set.ws(obj,val)
0142 %       if ~isnumeric(val) || numel(val) > 1 || val < 0 || ~isreal(val)
0143 %         error('### The <ws> property should be a positive real number.');
0144 %       end
0145       obj.ws = val;
0146     end
0147     function obj = set.ws2(obj,val)
0148 %       if ~isnumeric(val) || numel(val) > 1 || val < 0 || ~isreal(val)
0149 %         error('### The <ws2> property should be a positive real number.');
0150 %       end
0151       obj.ws2 = val;
0152     end
0153     function obj = set.win(obj,val)
0154 %       if ~isnumeric(val) || ~isreal(val)
0155 %         error('### The <win> property should be a positive real number.');
0156 %       end
0157       obj.win = val;
0158     end
0159 
0160     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0161     %                                Constructor                                %
0162     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0163     function ww = specwin(varargin)
0164       
0165       import utils.const.*
0166       utils.helper.msg(msg.OMNAME, 'running %s/%s', mfilename('class'), mfilename);
0167 
0168       %%% Call superclass
0169       ww = ww@ltpda_nuo(varargin{:});
0170 
0171       %%%%%%%%%%   Set dafault values   %%%%%%%%%%
0172       %%% Exept for a struct as an input
0173       if ~(nargin == 1 && isstruct(varargin{1}))
0174         % Set version
0175         ww.setVersion('$Id: specwin.m,v 1.52 2008/08/11 08:40:21 hewitson Exp $');
0176       end
0177 
0178       switch nargin
0179         case 0
0180           utils.helper.msg(msg.OPROC1, 'empty constructor');
0181         case 1
0182           if isa(varargin{1}, 'specwin')
0183             utils.helper.msg(msg.OPROC1, 'copy constructor');
0184             %%%%%%%%%%   spw = specwin(specwin-object)   %%%%%%%%%%
0185             % copy existing specwin
0186             ww = copy(varargin{1}, 1);
0187           elseif isstruct(varargin{1})
0188             utils.helper.msg(msg.OPROC1, 'constructing from struct');
0189             %%%%%%%%%%   spw = specwin(struct)   %%%%%%%%%%
0190 
0191             %%% Set properties which are declared in this class
0192             spw_struct = varargin{1};
0193 
0194             ww.type = spw_struct.type;
0195             ww.alpha = spw_struct.alpha;
0196             ww.psll = spw_struct.psll;
0197             ww.rov = spw_struct.rov;
0198             ww.nenbw = spw_struct.nenbw;
0199             ww.w3db = spw_struct.w3db;
0200             ww.flatness = spw_struct.flatness;
0201             ww.ws = spw_struct.ws;
0202             ww.ws2 = spw_struct.ws2;
0203             ww.win = spw_struct.win;
0204 
0205           elseif ischar(varargin{1})
0206             utils.helper.msg(msg.OPROC1, 'constructing from string');
0207             error('### Code up the char constructor.');
0208           end
0209         case 2
0210             utils.helper.msg(msg.OPROC1, 'constructing type %s', varargin{1});
0211           if ischar(varargin{1})
0212             %%%%%%%%%%   spw = specwin('Win_type', N)   %%%%%%%%%%
0213             ww = get_window(ww, varargin{1}, varargin{2});
0214           else
0215             error('### Unknown 2 argument constructor for specwin object.')
0216           end
0217         case 3
0218           utils.helper.msg(msg.OPROC1, 'constructing type %s', varargin{1});
0219           %%%%%%%%%%   spw = specwin('Kaiser', N, psll)   %%%%%%%%%%
0220           ww = get_window(ww, varargin{1}, varargin{2}, varargin{3});
0221         otherwise
0222           error('### Unknown number of constructor arguments');
0223       end % End of constructor
0224 
0225     end
0226 
0227     varargout = copy(varargin)
0228 
0229   end % End public methods
0230 
0231 
0232   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0233   %                          Methods (Static, Public)                         %
0234   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0235 
0236   methods (Static = true)
0237 
0238     varargout = update_struct(varargin);
0239 
0240     function ww = getTypes()
0241       ww = {...
0242         'Rectangular', 'Welch', 'Bartlett', 'Hanning', 'Hamming',...
0243         'Nuttall3', 'Nuttall4', 'Nuttall3a', 'Nuttall3b', 'Nuttall4a',...
0244         'Nuttall4b', 'Nuttall4c', 'BH92', 'SFT3F', 'SFT3M', 'FTNI', 'SFT4F', 'SFT5F',...
0245         'SFT4M', 'FTHP', 'HFT70', 'FTSRS', 'SFT5M', 'HFT90D', 'HFT95', 'HFT116D',...
0246         'HFT144D', 'HFT169D', 'HFT196D', 'HFT223D', 'HFT248D'...
0247         };
0248     end
0249 
0250     function out = VEROUT()
0251       out = '$Id: specwin.m,v 1.52 2008/08/11 08:40:21 hewitson Exp $';
0252     end
0253 
0254     function ii = getInfo(varargin)
0255       ii = utils.helper.generic_getInfo(varargin{:}, 'specwin');
0256     end
0257 
0258     function out = SETS()
0259       out = {'Default'};
0260     end
0261 
0262     function out = getDefaultPlist(set)
0263       switch set
0264         case 'Default'
0265           out = plist();
0266         otherwise
0267           out = plist();
0268       end
0269     end
0270 
0271   end % End static methods
0272 
0273   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0274   %                          Methods (Static, Private)                        %
0275   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0276 
0277   methods (Static = true, Access = private)
0278 
0279     varargout = kaiser_alpha(varargin)
0280     varargout = kaiser_flatness(varargin)
0281     varargout = kaiser_nenbw(varargin)
0282     varargout = kaiser_rov(varargin)
0283     varargout = kaiser_w3db(varargin)
0284 
0285   end % End static private methods
0286 
0287   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0288   %                              Methods (protected)                          %
0289   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0290 
0291   methods (Access = protected)
0292     varargout = get_window(varargin)
0293     varargout = win_BH92(varargin)
0294     varargout = win_Bartlett(varargin)
0295     varargout = win_FTHP(varargin)
0296     varargout = win_FTNI(varargin)
0297     varargout = win_FTSRS(varargin)
0298     varargout = win_HFT116D(varargin)
0299     varargout = win_HFT144D(varargin)
0300     varargout = win_HFT169D(varargin)
0301     varargout = win_HFT196D(varargin)
0302     varargout = win_HFT223D(varargin)
0303     varargout = win_HFT248D(varargin)
0304     varargout = win_HFT70(varargin)
0305     varargout = win_HFT90D(varargin)
0306     varargout = win_HFT95(varargin)
0307     varargout = win_Hamming(varargin)
0308     varargout = win_Hanning(varargin)
0309     varargout = win_Nuttall3(varargin)
0310     varargout = win_Nuttall3a(varargin)
0311     varargout = win_Nuttall3b(varargin)
0312     varargout = win_Nuttall4(varargin)
0313     varargout = win_Nuttall4a(varargin)
0314     varargout = win_Nuttall4b(varargin)
0315     varargout = win_Nuttall4c(varargin)
0316     varargout = win_Rectangular(varargin)
0317     varargout = win_SFT3F(varargin)
0318     varargout = win_SFT3M(varargin)
0319     varargout = win_SFT4F(varargin)
0320     varargout = win_SFT4M(varargin)
0321     varargout = win_SFT5F(varargin)
0322     varargout = win_SFT5M(varargin)
0323     varargout = win_Welch(varargin)
0324   end
0325 
0326 end % End classdef
0327 
0328 
0329 
0330

Generated on Mon 25-Aug-2008 22:39:29 by m2html © 2003