Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Widmo sygnału przed odfiltrowaniem
- Y= fft(y);
- L=length(y);
- P2 = abs(Y/L);
- P1 = P2(1:L/2+1);
- P1(2:end-1) = 2*P1(2:end-1);
- f = fs*(0:(L/2))/L;
- figure(1)
- plot(f,P1)
- xlabel('f (Hz)')
- ylabel('|P1(f)|')
- ylim([0 0.35])
- title("Widmo częstotliwościowe sygnału z pliku")
- %% Przebieg sygnału
- t=0:1:numel(y)-1;
- figure(2)
- plot(t,y)
- title("Przebieg sygnału przed odfiltrowaniem")
- xlim([0 146225])
- %% Filtr tłumiący do 170Hz
- Wpc=170/(0.5*fs);
- Wsc=140/(0.5*fs);
- Rpc=3;
- Rsc=40;
- [nc,Wnc] = cheb1ord(Wpc,Wsc,Rpc,Rsc)
- [bc,ac] = cheby1(nc,Rpc,Wnc,'high')
- Gc=tf(bc,ac,1/fs)
- options = bodeoptions;
- options.FreqUnits = 'Hz';
- options.FreqScale = 'linear'
- figure(3)
- bode(Gc, options)
- xlim([0 4700])
- %% Pierwsze zakłócenie
- Wpc21=[605 615]/(0.5*fs)
- Wsc21=[595 625]/(0.5*fs)
- Rpc21=3;
- Rsc21=45;
- [nc21,Wnc21]=cheb2ord(Wpc21,Wsc21,Rpc21,Rsc21)
- [bc21,ac21]=cheby2(nc21,Rsc21,Wnc21,'stop')
- GC21=tf(bc21,ac21,1/fs)
- figure(4)
- options = bodeoptions;
- options.FreqUnits = 'Hz';
- options.FreqScale = 'linear'
- bode(GC21, options)
- xlim([400 800])
- %% Drugie zakłócenie
- Wpc22=[2475 2490]/(0.5*fs)
- Wsc22=[2470 2495]/(0.5*fs)
- Rpc22=3;
- Rsc22=45;
- [nc22,Wnc22]=cheb2ord(Wpc22,Wsc22,Rpc22,Rsc22)
- [bc22,ac22]=cheby2(nc22,Rsc22,Wnc22,'stop')
- GC22=tf(bc22,ac22,1/fs)
- figure(5)
- options = bodeoptions;
- options.FreqUnits = 'Hz';
- options.FreqScale = 'linear'
- bode(GC22, options)
- xlim([2400 2600])
- %% Przepuszczenie sygnału przez filtry
- sygfilter1=filter(bc,ac,y);
- sygfilter2=filter(bc21,ac21,sygfilter1);
- sygfilter3=filter(bc22,ac22,sygfilter2);
- %% Widmo sygnału po dofiltrowaniu zakłóceń
- Y= fft(sygfilter3);
- L=length(sygfilter3);
- fs=9000;
- P2 = abs(Y/L);
- P1 = P2(1:L/2+1);
- P1(2:end-1) = 2*P1(2:end-1);
- f = fs*(0:(L/2))/L;
- figure(6)
- plot(f,P1)
- xlabel('f (Hz)')
- ylabel('|P1(f)|')
- title("Widmo częstotliwościowe sygnału po odfiltrowaniu")
- %% Odfiltrowany sygnał
- t=0:1:numel(y)-1;
- figure(7)
- plot(t,sygfilter3)
- title("Przebieg zadanego sygnału po odfiltrowaniu")
- %% Odtworzenie sygnału
- sound(sygfilter3,fs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement