Advertisement
makispaiktis

PSES_Comparison_rekanos

Nov 2nd, 2020 (edited)
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.03 KB | None | 0 0
  1. clear all
  2. clc
  3.  
  4. x = cos(0.5 * [1:1:20]);
  5. h = 0.1 * abs([1:1:20] - 10);
  6. y = conv(x, h)    % 39 deigmata = 20+20-1
  7.  
  8. plot(x, 'red');
  9. hold on
  10. plot(h, 'blue');
  11. hold on
  12. plot(y, 'black')
  13.  
  14. X = fft(x);
  15. H = fft(h);             % Complex me 20 deigmata
  16. Ytest = X .* H;         % Diastasi = 20
  17. figure
  18. plot(abs(X), 'red');
  19. hold on
  20. plot(abs(H), 'blue');
  21. hold on
  22. plot(abs(Ytest), 'black');
  23. % Nai, alla to mauro fasma Ytest einai o DFT tou y = x synelixi h?
  24. % Kati tetoio den isxyei
  25. % Tha to dw to lathos me ifft
  26. ytest = ifft(Ytest);
  27. plot(ytest, '+');
  28. % To ytest einai lathos exei 20 anti 39
  29.  
  30. % ZERO PANTING = SWSTO
  31. xx = zeros(1,39);
  32. xx(1:20) = x;
  33. figure
  34. plot(xx, 'red');
  35.  
  36. hh = zeros(1,39);
  37. hh(1:20) = h;
  38. hold on
  39. plot(hh, 'blue');
  40.  
  41. XX = fft(xx);
  42. HH = fft(hh);
  43. figure
  44. plot(abs(XX), 'red');
  45. hold on
  46. plot(abs(HH), 'blue');
  47. YY = XX .* HH;
  48. plot(abs(YY), 'black');
  49. % Tha dw me ton ifft kati me 39 deigmata kai sygkekrimena ayto to mauto tou
  50. % figure1
  51. yy = real(ifft(YY));    % Gia ypologistikes astoxies to real()
  52. plot(yy, '*')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement