Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %filtr butterwortha srodkowoprzepustowy
- %fgr1=1000Hz, fgr2=1500Hz
- %Częstotlwiośc próbkowania fs=8000Hz
- %nie przesadź z rzędem (do 20?)
- %butter
- %przy użyciu filtru wyfiltrować sume 2 sinusów f1=500Hz,
- %f2=1250 i szumu przy użyciu funkcji filter
- %wykreślic moduł funkcji transmitancji filtru, widmo przed i po filtracji
- clear all; clf;
- n=10;
- fgr1=1000;
- fgr2=1500;
- fs=8000;
- w1=fgr1/(fs/2);
- w2=fgr2/(fs/2);
- Wn=[w1 w2];
- [b,a]=butter(n,Wn);
- f1=500;
- f2=1250;
- dt=1/fs;
- t=0:dt:(fs-1)*dt;
- x1=sin(2*pi*f1*t);
- x2=sin(2*pi*f2*t);
- szum=randn(1,length(x1));
- x=x1+x2+szum;
- X=filter(b,a,x);
- figure(1)
- H=freqz(b,a);
- Habs=abs(H);
- Hmax=max(Habs);
- HdB=20*log10(Habs/Hmax);
- df=0.5*fs/length(Habs);
- f=0:df:0.5*fs-df;
- subplot(321)
- plot(f,Habs); grid on;
- title('|H(f)|-skala liniowa')
- subplot(322)
- plot(f,HdB);grid on;
- ylabel('[dB]')
- title('|H(f)|-skala logarytmiczna')
- %przed
- x11=fft(x);
- x1_modul=abs(x11);
- %po
- x12=fft(X);
- x2_modul=abs(x12);
- T=1;
- N=T*fs;
- dff=fs/N;
- f3=0:dff:(N-1)*dff;
- subplot(323)
- stem(f3,x1_modul,'.'); grid on
- xlabel('czestotliwość [Hz]')
- title(['widmo amplitudowe przed filtracja, fs=', num2str(fs), ' [Hz]'])
- subplot(325)
- stem(f3,x2_modul,'.'); grid on
- xlabel('czestotliwość [Hz]')
- title(['widmo amplitudowe po filtracj, fs=', num2str(fs), ' [Hz]'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement