Speed up MATLAB filter command

2019-09-02 10:35发布

I am relatively new to using MATLAB filters. I am trying to filter a fairly large data set (about 2 million data points) using the following commands

rrc = rcosdesign(0.25, 10, floor(Fs/symRate), 'sqrt');
filtered = filter(rrc, 1, samples);
filtered = filtered / sqrt(floor(Fs/symRate));

When I run the MATLAB Profiler, it says the line

filtered = filter(rrc, 1, samples);

takes over 500 seconds to run. Any ideas on how to speed this up? I have tried using a FilterM function I found online ( http://www.mathworks.com/matlabcentral/fileexchange/32261-filterm ) but it takes the same amount of time. Anyone else have any ideas?

Thanks in advance

1条回答
戒情不戒烟
2楼-- · 2019-09-02 11:19

Few Ideas:

  1. If you have FIR filter (As it seems from the code) you may gain performance using conv2 which uses Intel IPP which might speed things up. Use the 'valid' flag to get filter results.
  2. If the filter is long and the data is long, try using xcorr as it uses FFT to speed up correlations. Since you're after filtering, remember to flip your filter coefficients.
  3. Compile filterX using Visual Studio 2013 or even better Intel C Compiler 2013 with optimization flags (/03). When using it, use the filterX command directly (Skip FilterM wrapper).
  4. Use FFT manually to perform convolution.
  5. Create a MEX version of Intel MKL / Intel IPP filter function.

Any of these should help considerably.

查看更多
登录 后发表回答