Clear Filters
Clear Filters

dsp.FIRRateConverter has unexpected results

1 view (last 30 days)
I am trying to resample a complex signal and the output of the filter is not what I expect. I expect the output of the following example to be a smooth complex sinusoid, but it seems to have misaligned samples.
filt = dsp.FIRRateConverter;
filt.InterpolationFactor = 8;
filt.DecimationFactor = 2;
x = exp(1i * 2 * pi * [1:100] * 1 / 10).';
y = step(filt,x);
figure(1);plot(real(x))
figure(2);plot(real(y(:)))

Accepted Answer

Andy
Andy on 5 Jul 2017
Edited: Andy on 6 Jul 2017
It works for those particular values, but I need to work with a range of values. Here's a better example of the problem. Notice that the "resample" function works properly, but for my primary application I am required to use the "dsp" object, which has the problem.
filt = dsp.FIRRateConverter;
filt.InterpolationFactor = 8;
filt.DecimationFactor = 5;
x = exp(1i * 2 * pi * [1:100] * 1 / 10).';
y = step(filt,x);
z = resample(x,filt.InterpolationFactor,filt.DecimationFactor);
figure(1);
subplot(3,1,1);plot(real(x))
subplot(3,1,2);plot(real(y(:)))
subplot(3,1,3);plot(real(z))
  1 Comment
Honglei Chen
Honglei Chen on 6 Jul 2017
In this case, the default filter (see documentation) is not suitable since the cutoff is too high and it introduces the aliasing. Change the filter to
filt.Numerator = firpm(70,[0 0.125 0.2 1],[1 1 0 0]);
and you'll see the right result. However, it also has some group delay effect in it.
The resample designs the filter for you and compensate for the group delay, but it does not work if you have streaming data. That's probably the tradeoff.
HTH

Sign in to comment.

More Answers (1)

Honglei Chen
Honglei Chen on 1 Jul 2017
Is there any reason your up and down converter factor is 8 and 2 instead of 4 and 1? Based on the documentation at
"You must use upsampling and downsampling factors that are relatively prime, or coprime." Changing it to 4 and 1 seems to give reasonable results
HTH

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!