Filter_IFFT.m 851 B

12345678910111213141516171819202122232425262728
  1. function [outtrace] = Filter_IFFT(intrace, frq1, frq2, sfrq, no)
  2. % Calc FFT-like square------
  3. fmax=sfrq/2;
  4. ll = length(intrace);
  5. if mod(length(intrace),2) > 0
  6. intrace = intrace(1:ll-1);
  7. end
  8. Fpts = length(intrace)/2;
  9. lpfrqs=round(Fpts*frq1/fmax);
  10. if lpfrqs < 1
  11. lpfrqs = 1;
  12. end
  13. hpfrqs=round(Fpts*frq2/fmax);
  14. Fwindow = ones(1,Fpts)*0.0000001;
  15. Fwindow(lpfrqs:hpfrqs)=1;
  16. Fwindow = [Fwindow fliplr(Fwindow)]';
  17. if no == 1
  18. Fwindow = Fwindow +1;
  19. Fwindow = mod(Fwindow,2);
  20. end
  21. %----------------------------
  22. FFT = fft(intrace);
  23. mag = abs(FFT);
  24. mag = (mag.*Fwindow); % .* elementwise multiplication and exch row/columns
  25. phase = angle(FFT); % exch row/columns
  26. % % ifft---------------------
  27. filteredSpec =mag.*exp(1i.*phase); % Lu .* array multiplication
  28. outtrace=real(ifft(filteredSpec))'; % % exch row/columns Lu