download morlet.m
Language: Matlab
License: GPL
Copyright: Copyright 1994,1995,1996 Universidad de Vigo
LOC: 18
Project Info
MatLinks/Chorus(matlinks)
Server: SourceForge
Type: cvs
...opyleft\gpl\chorale\signal\
   average.m
   beatfreq.m
   Contents.m
   envelope.m
   findpeak.m
   morlet.m
   phdiff.m
   smooth.m
   zcross.m

% MORLET  ( Universidad de Vigo) Produce the Morlet Wavelet.
%
%        t-B        1      j*W0*(t-B)/A    -.5*((t-B)/A)^2
%    G ( --- ) =  ----- * e             * e
%         A       A^.5
%
%    A is dimensionless and B has units of time.
%
%    G=MORLET(FS,A) computes the Morlet wavelet with scaling factor A and
%    sampled with frequency FS (Hz).
%
%    G=MORLET(FS,A,B) time-shifts the wavelet by B seconds.  The default
%    value for B=0 (s).
%
%    G=MORLET(FS,A,B,W0) changes the central frequency of the wavelet to W0.
%    The default value of W0=2*PI (rad/s).
%
%    G=MORLET(FS,A,B,W0,T) changes the domain of the wavelet to T.  The default
%    value for T=(-6:1:+6) (s), because the values of the Morlet wavelet are
%    negligible for ABS(t)>6*DT.
%
%    Example: T=(-10:0.001:+5) changes the domain to -10 s. minimum and +5 s.
%    maximum, with a resolution of 0.001 s. (1 ms).
%
%    The scaled wavelet is calculated by compressing or expanding the scale by
%    one wavelet.  This last is computed in the interval T, and compressions or
%    dilations modify this interval as well.
%
%    [G,T]=MORLET(...) also returns the time domain of the wavelet.
%
%    See also SCALOG.
%
%    Type HELP MATLINKS for a full listing of all MatLinks ToolChest functions.
%
function [w,t]=morlet(fs,a,b,w0,t)
%===============================================================================
%  Copyright  1994,1995,1996 Universidad de Vigo
%  Use & distribution covered by GNU General Public License (www.gnu.org)
%-------------------------------------------------------------------------------
% Uvi_Wave is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation; either version 2, or (at your option) any
% later version.
%
% Uvi_Wave is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU General Public License
% along with Uvi_Wave; see the file COPYING.  If not, write to the Free
% Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
%
%       Author: Nuria Gonzalez Prelcic
%       e-mail: Uvi_Wave@tsc.uvigo.es
%===============================================================================

%-----------------------------------------------------------------------------
% parse the inputs
%-----------------------------------------------------------------------------
if (nargin < 3),
  b = 0;
end;
if (nargin < 4),
  w0 = 2*pi;
end;
if (nargin < 5),
  t = (-6:+6);
elseif (max(abs(t)) < 5),
  disp('WARNING: Small time interval.  Wavelet end(s) may be too abrupt.');
end;

%-----------------------------------------------------------------------------
% Find the number of points according to the sampling rate and the time space
%-----------------------------------------------------------------------------
fs = fs / mean(diff(t));
n = (max(t)-min(t)) * fs + 1;
res = (max(t)-min(t)) / n;
N = (max(t)-min(t)) * a / res;          % number of points for the scaled wavelet
t = linspace(min(t)*a, max(t)*a, N);    % time domain for the scaled wavelet

%-----------------------------------------------------------------------------
% compute the wavelet
%-----------------------------------------------------------------------------
w = sqrt(1/a) * exp(i*w0*(t-b)/a) .* exp(-((t-b)/a).^2/2);

%===============================================================================
% End-Of-File
%===============================================================================

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us