Advertisement
Guest User

lab12_12

a guest
Dec 12th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. close all; clear; clc;
  2. %t=<-10,10>s, Fs = 200Hz
  3. %x = suma x1:x3
  4. %x1 harm, amp. rosnaca od 0.7 do 0.9, f=27Hz
  5. %x2 sygn trojkatny , tw=0, szer=6s, amp=0.7
  6. %x3 harm, amp=0.6, okres=0.05s
  7. %sygnal, policz WA
  8. %wykresy
  9. Fs=200;
  10. t=-10:1/200:10;
  11. x1 = linspace(0.7,0.9,length(t)).*sin(2*pi*27*t);
  12. x2 = 0.7*(1-abs(t)/3).*(t>=-3&t<=3);
  13. %x2 = 0.7*(1-abs(t)/3).*(abs(t)<3);
  14. x3 = 0.6*sin(2*pi*t/0.05);
  15. x=x1+x2+x3;
  16. XT=fftshift(fft(x));
  17. WA=abs(XT);
  18. %f=linspace(-100,100,length(t));
  19. f=10*t;
  20. %BS=1.0*(abs(f)<15 | abs(f)>23);
  21. %LP=1.0./(1+(f/23).^12);
  22. %gauss
  23. LP=exp(-f.*f/(2*23^2));
  24. %x_new=real(ifft(ifftshift(BS.*XT)));
  25. x_new=real(ifft(ifftshift(LP.*XT)));
  26. %subplot(211), plot(t,x);
  27. %subplot(212), plot(f,WA);
  28.  
  29. subplot(211), plot(t,x,'r',t,x_new,'b');
  30. subplot(212), plot(f,WA,'r',f,LP*Fs,'b');
  31.  
  32. %%
  33. close all; clear; clc;
  34. %t=0-10; Fs=100Hz
  35. %x - prostokatny, amp=2, szer=4, srodek=5
  36. %zrobic wykres sygnalu i WA
  37. Fs=100;
  38. t=0:1/Fs:10;
  39. x = 2*(abs(t-5)<2);
  40. XT = fftshift(fft(x));
  41. WA = abs(XT);
  42.  
  43. f=(t-5)*10;
  44. %subplot(211), plot(t,x);
  45. %subplot(212), plot(f,WA);
  46.  
  47. %filtracja dolnoprzepustowa
  48. %filtr maska dolnoprzepustowa
  49. LP=1.0*(abs(f)<=5);
  50. LP2=1.0./(1+(f/5).^8);
  51. LP3=exp(-f.*f/50);
  52. x1=ifft(ifftshift(LP.*XT));
  53. x2=ifft(ifftshift(LP2.*XT));
  54. x3=ifft(ifftshift(LP3.*XT));
  55. %gornoprzepustowa
  56. %LP=1.0*(abs(f)>5);
  57. %filtracja - mnozymy filtr przez transformate
  58. XT_new = LP.*XT;
  59. x_new=ifft(ifftshift(XT_new));
  60. %subplot(211), plot(t,x,'r',t,x_new,'g');
  61. %subplot(212), plot(f,WA,'r',f,Fs*LP,'g');
  62. subplot(211), plot(t,x,'r',t,x1,'g',t,x2,'b',t,x3,'k');
  63. 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