Home > phiwave > uvi_wave > center.m

center

PURPOSE ^

CENTER Delay calculation for Wavelet transform alignment.

SYNOPSIS ^

function d=center(x,op);

DESCRIPTION ^

  CENTER  Delay calculation for Wavelet transform alignment.

          CENTER (X, OP) calculates the delay for filter in X 
          according to the alignment method indicated in OP. 
          This delay is used by Wavelet transform functions.
          The value of OP can be:
              0 : First Absolute Maxima Location
              1 : Zero delay in analysis (Full for synthesis).
              2 : Mass center (sum(m*d)/sum(m))
              3 : Energy center (sum(m^2 *d)/sum(m^2))

          If no output argument is given, then the vector X will
          be plotted in the current figure, and a color line will be 
          marking the result.(red: OP=0; green: OP=1; cyan: OP=2; 
          blue: OP=4)

          See also: WTCENTER, WTMETHOD

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function d=center(x,op);
0002 
0003 %  CENTER  Delay calculation for Wavelet transform alignment.
0004 %
0005 %          CENTER (X, OP) calculates the delay for filter in X
0006 %          according to the alignment method indicated in OP.
0007 %          This delay is used by Wavelet transform functions.
0008 %          The value of OP can be:
0009 %              0 : First Absolute Maxima Location
0010 %              1 : Zero delay in analysis (Full for synthesis).
0011 %              2 : Mass center (sum(m*d)/sum(m))
0012 %              3 : Energy center (sum(m^2 *d)/sum(m^2))
0013 %
0014 %          If no output argument is given, then the vector X will
0015 %          be plotted in the current figure, and a color line will be
0016 %          marking the result.(red: OP=0; green: OP=1; cyan: OP=2;
0017 %          blue: OP=4)
0018 %
0019 %          See also: WTCENTER, WTMETHOD
0020 
0021 
0022 %--------------------------------------------------------
0023 % Copyright (C) 1994, 1995, 1996, by Universidad de Vigo
0024 %
0025 %
0026 % Uvi_Wave is free software; you can redistribute it and/or modify it
0027 % under the terms of the GNU General Public License as published by the
0028 % Free Software Foundation; either version 2, or (at your option) any
0029 % later version.
0030 %
0031 % Uvi_Wave is distributed in the hope that it will be useful, but WITHOUT
0032 % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0033 % FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0034 % for more details.
0035 %
0036 % You should have received a copy of the GNU General Public License
0037 % along with Uvi_Wave; see the file COPYING.  If not, write to the Free
0038 % Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
0039 %
0040 %       Author: Sergio J. Garcia Galan
0041 %       e-mail: Uvi_Wave@tsc.uvigo.es
0042 %--------------------------------------------------------
0043 
0044 
0045 lx=length(x);
0046 l=1:lx;
0047 
0048 if op==1
0049     d=0;
0050 else
0051     if op==2
0052         xx=abs(x(:)');
0053         L=l;
0054     end
0055     if op==3
0056         xx=x(:)'.^2;
0057         L=l;
0058     end
0059     if op==0
0060         [mx,d]=max(abs(x));
0061     else 
0062         
0063         d=sum(xx.*L)/sum(xx);
0064     end
0065 end
0066 
0067 if nargout==0,
0068   cad='rgcbk';
0069   plot(x)
0070   l=line([d,d],[min(x),max(x)]);
0071   set(l,'Color',cad(op+1));
0072 end

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