Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- close all; clear; clc;
- %t=<-10,10>s, Fs = 200Hz
- %x = suma x1:x3
- %x1 harm, amp. rosnaca od 0.7 do 0.9, f=27Hz
- %x2 sygn trojkatny , tw=0, szer=6s, amp=0.7
- %x3 harm, amp=0.6, okres=0.05s
- %sygnal, policz WA
- %wykresy
- Fs=200;
- t=-10:1/200:10;
- x1 = linspace(0.7,0.9,length(t)).*sin(2*pi*27*t);
- x2 = 0.7*(1-abs(t)/3).*(t>=-3&t<=3);
- %x2 = 0.7*(1-abs(t)/3).*(abs(t)<3);
- x3 = 0.6*sin(2*pi*t/0.05);
- x=x1+x2+x3;
- XT=fftshift(fft(x));
- WA=abs(XT);
- %f=linspace(-100,100,length(t));
- f=10*t;
- %BS=1.0*(abs(f)<15 | abs(f)>23);
- %LP=1.0./(1+(f/23).^12);
- %gauss
- LP=exp(-f.*f/(2*23^2));
- %x_new=real(ifft(ifftshift(BS.*XT)));
- x_new=real(ifft(ifftshift(LP.*XT)));
- %subplot(211), plot(t,x);
- %subplot(212), plot(f,WA);
- subplot(211), plot(t,x,'r',t,x_new,'b');
- subplot(212), plot(f,WA,'r',f,LP*Fs,'b');
- %%
- close all; clear; clc;
- %t=0-10; Fs=100Hz
- %x - prostokatny, amp=2, szer=4, srodek=5
- %zrobic wykres sygnalu i WA
- Fs=100;
- t=0:1/Fs:10;
- x = 2*(abs(t-5)<2);
- XT = fftshift(fft(x));
- WA = abs(XT);
- f=(t-5)*10;
- %subplot(211), plot(t,x);
- %subplot(212), plot(f,WA);
- %filtracja dolnoprzepustowa
- %filtr maska dolnoprzepustowa
- LP=1.0*(abs(f)<=5);
- LP2=1.0./(1+(f/5).^8);
- LP3=exp(-f.*f/50);
- x1=ifft(ifftshift(LP.*XT));
- x2=ifft(ifftshift(LP2.*XT));
- x3=ifft(ifftshift(LP3.*XT));
- %gornoprzepustowa
- %LP=1.0*(abs(f)>5);
- %filtracja - mnozymy filtr przez transformate
- XT_new = LP.*XT;
- x_new=ifft(ifftshift(XT_new));
- %subplot(211), plot(t,x,'r',t,x_new,'g');
- %subplot(212), plot(f,WA,'r',f,Fs*LP,'g');
- subplot(211), plot(t,x,'r',t,x1,'g',t,x2,'b',t,x3,'k');
- subplot(212), plot(f,WA,'r',f,Fs*LP,'g',f,Fs*LP2,'b',f,Fs*LP3,'k');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement