annotate aim-mat/tools/@signal/highpass.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 20ada0af3d7d
children
rev   line source
tomwalters@0 1 % method of class @signal
tomwalters@0 2 %
tomwalters@0 3 % INPUT VALUES:
tomwalters@0 4 %
tomwalters@0 5 % RETURN VALUE:
tomwalters@0 6 %
bleeck@3 7 % This external file is included as part of the 'aim-mat' distribution package
bleeck@3 8 % (c) 2011, University of Southampton
bleeck@3 9 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 10 % download of current version is on the soundsoftware site:
bleeck@3 11 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 12 % documentation and everything is on http://www.acousticscale.org
bleeck@3 13
tomwalters@0 14
tomwalters@0 15 function sig=highpass(sig,frequency,stopband,ripple,stopbandatten)
tomwalters@0 16 % hack for an phase true lowpassfilter with cutoff at frequency
tomwalters@0 17 % used is a ButterworthFilter
tomwalters@0 18
tomwalters@0 19 if nargin < 5
tomwalters@0 20 stopbandatten=60; % in dB - how many dB the signal is reduced in the stopband at least
tomwalters@0 21 end
tomwalters@0 22 if nargin < 4
tomwalters@0 23 ripple=1; % in dB = ripple in the passband
tomwalters@0 24 end
tomwalters@0 25 if nargin <3
tomwalters@0 26 stopband=frequency/2; % eine Oktave drunter
tomwalters@0 27 end
tomwalters@0 28
tomwalters@0 29 nyquist=getsr(sig)/2;
tomwalters@0 30 fre_low=frequency;
tomwalters@0 31
tomwalters@0 32 % passband
tomwalters@0 33 wp=[fre_low/nyquist 0.98];
tomwalters@0 34
tomwalters@0 35 % stopband
tomwalters@0 36 ws=[(fre_low-stopband)/nyquist 0.99];
tomwalters@0 37
tomwalters@0 38 % Finde raus, wieviel Punkte der Filter dafür haben muss
tomwalters@0 39 [n,Wn] = buttord(wp,ws,ripple,stopbandatten);
tomwalters@0 40 % Berechne den IIR-Filter
tomwalters@0 41 [b,a] = butter(n,Wn);
tomwalters@0 42
tomwalters@0 43 % testen:
tomwalters@0 44 % freqz(b,a,512,getsr(sig));
tomwalters@0 45
tomwalters@0 46 vals=sig.werte;
tomwalters@0 47 nvals = filtfilt(b,a,vals);
tomwalters@0 48 sig.werte=nvals;