Azzera filtri
Azzera filtri

"mfilt.firsrc will be removed in a future release"

8 visualizzazioni (ultimi 30 giorni)
I'm using the "hm.persistentmemory" aspect of this filter, after defining hm = mfilt.firsrc(1,2). I continue to get the warning "mfilt.firsrc will be removed in a future release. Use dsp.FIRRateConverter instead.", but this dsp object doesn't have the persistent memory feature that I need. How do I implement a sample rate converter with persistent memory in the new recommended function?

Risposta accettata

Honglei Chen
Honglei Chen il 29 Giu 2017
What PersistentMemory does is to keep the state in the filter so if the data is streamed in, it would filter properly as if the data is fed in all at once.
On the other hand, for dsp.FIRRateConverter, the state is always remembered, so you don't really need that flag any more. In the example below I just want to show you that the two can arrive at the same result
f1 = mfilt.firsrc(1,2)
f1.PersistentMemory = true
f2 = dsp.FIRRateConverter
f2.InterpolationFactor = 1;
f2.DecimationFactor = 2
f2.Numerator = f1.Numerator
So here we make sure the two filters are setup the same now we'll filter the same data
x = randn(100,1);
y1 = filter(f1,x);
y2 = f2(x);
isequal(y1,y2)
The results for the first segment of signal are the same
y1 = filter(f1,x);
y2 = f2(x);
isequal(y1,y2)
The results for the second segment of streamed signal are still the same so they work the same way.
HTH
  3 Commenti
Honglei Chen
Honglei Chen il 30 Giu 2017
You should be able to do the same thing with dsp.FIRRateConverter
reset(f2); % Clear filter history.
yloop = zeros(20,5); % Preallocate output array.
xblock = reshape(x,[20 5]);
for i=1:5
yloop(:,i) = f2(xblock(:,i));
end
Essentially it maintains the state from one run to the next, as shown in the example above.
HTH
Andy
Andy il 30 Giu 2017
Thank you, that looks good. For completeness, here is a script that tests the new version:
x = randn(100,1);
filt = dsp.FIRRateConverter;
filt.InterpolationFactor = 1;
filt.DecimationFactor = 2;
y = step(filt,x);
reset(filt);
release(filt);
xblock = reshape(x,[20 5]);
for i=1:5
yloop(:,i) = step(filt,xblock(:,i));
end
stem([yloop(:) y]);
isequal(yloop(:),y)

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by