annotate aim-mat/modules/pcp/map/TaperWindow.m @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 74dedb26614d
children
rev   line source
tomwalters@0 1 %
tomwalters@0 2 % Taper Window Generator for signal onset/offset
tomwalters@0 3 % 7 Apr. 1993
tomwalters@0 4 % 29 Aug. 96
tomwalters@0 5 % IRINO Toshio
tomwalters@0 6 %
tomwalters@0 7 % function [TaperWin, TypeTaper] = ...
tomwalters@0 8 % TaperWindow(LenWin,TypeTaper,LenTaper,RangeSigma,SwPlot)
tomwalters@0 9 % INPUT LenWin : Length of Window (Number of points)
tomwalters@0 10 % TypeTaper : Type of Taper (KeyWords of 3 letters)
tomwalters@0 11 % (Hamming, Hanning (=cosine^2), Blackman, Gauss, Line)
tomwalters@0 12 % LenTaper : Length of Taper (Number of points)
tomwalters@0 13 % RangeSigma: Range in Sigma (default: 3) for Gauss
tomwalters@0 14 % SwPlot : 0) Omit plotting, 1) Plot Taper
tomwalters@0 15 % OUTPUT TaperWin : Taper Window Points (max==1);
tomwalters@0 16 % TypeTaper : Type of Taper (Full Name)
tomwalters@0 17 %
tomwalters@0 18 function [TaperWin, TypeTaper] = ...
tomwalters@0 19 TaperWindow(LenWin,TypeTaper,LenTaper,RangeSigma,SwPlot)
tomwalters@0 20
tomwalters@0 21 if nargin < 2,
tomwalters@0 22 help TaperWindow
tomwalters@0 23 error([ 'Specify Type of Taper : ' ...
tomwalters@0 24 ' Hamming, Hanning (=cosine^2), Blackman, Gauss, Line ']);
tomwalters@0 25 %TaperWin = ones(1,LenWin);
tomwalters@0 26 %return;
tomwalters@0 27 end;
tomwalters@0 28
tomwalters@0 29 if nargin < 3, LenTaper = fix(LenWin/2); end;
tomwalters@0 30 if nargin < 4, RangeSigma = 3; end;
tomwalters@0 31
tomwalters@0 32 if LenTaper*2 >= LenWin,
tomwalters@0 33 disp('Caution (TaperWindow.m) : No flat part. ');
tomwalters@0 34 if LenTaper ~= fix(LenWin/2),
tomwalters@0 35 disp('Caution (TaperWindow.m) : LenTaper <-- fix(LenWin/2)');
tomwalters@0 36 end;
tomwalters@0 37 LenTaper = fix(LenWin/2);
tomwalters@0 38 end;
tomwalters@0 39
tomwalters@0 40 if nargin < 5, SwPlot = 0; end; % changing default Swplot 29 Aug. 96
tomwalters@0 41
tomwalters@0 42 %TypeTaper = lower(TypeTaper(1:3));
tomwalters@0 43
tomwalters@0 44 if upper(TypeTaper(1:3)) == 'HAM',
tomwalters@0 45 Taper = hamming(LenTaper*2)';
tomwalters@0 46 TypeTaper = 'Hamming';
tomwalters@0 47 elseif upper(TypeTaper(1:3)) == 'HAN' | upper(TypeTaper(1:3)) == 'COS',
tomwalters@0 48 Taper = hanning(LenTaper*2)';
tomwalters@0 49 TypeTaper = 'Hanning/Cosine';
tomwalters@0 50 elseif upper(TypeTaper(1:3)) == 'BLA',
tomwalters@0 51 Taper = blackman(LenTaper*2)';
tomwalters@0 52 TypeTaper = 'Blackman';
tomwalters@0 53 elseif upper(TypeTaper(1:3)) == 'GAU',
tomwalters@0 54 if length(RangeSigma) == 0, RangeSigma = 3; end;
tomwalters@0 55 nn = -LenTaper+0.5:1:LenTaper-0.5;
tomwalters@0 56 Taper = exp(-(RangeSigma*nn/LenTaper).^2 /2);
tomwalters@0 57 TypeTaper = 'Gauss';
tomwalters@0 58 else Taper = [1:LenTaper LenTaper:-1:1]/LenTaper; % 'line',
tomwalters@0 59 TypeTaper = 'Line';
tomwalters@0 60 end;
tomwalters@0 61
tomwalters@0 62 %plot(Taper)
tomwalters@0 63 %size(Taper);
tomwalters@0 64 LenTaper = fix(LenTaper);
tomwalters@0 65 TaperWin = [ Taper(1:LenTaper) ones(1,LenWin-LenTaper*2) ...
tomwalters@0 66 Taper(LenTaper+1:LenTaper*2)];
tomwalters@0 67
tomwalters@0 68 if SwPlot == 1,
tomwalters@0 69
tomwalters@0 70 plot(TaperWin)
tomwalters@0 71 xlabel('Points');
tomwalters@0 72 ylabel('Amplitude');
tomwalters@0 73 title(['TypeTaper = ' TypeTaper] );
tomwalters@0 74
tomwalters@0 75 end;
tomwalters@0 76