Get states from a fdesign.bandpass object and use in filter function

3 views (last 30 days)
Hi all,
I designed several bandpasses using
hband = fdesign.bandpass(....)
Hband = design(hband,'cheby1','MatchExactly','passband');
What I want to do is split the input in frequency bands and filter each with a FIR filter. This works fine but the problem is the bandpass - I have a long signal and I chop it in 1024 sample frames. I therefore need to save the states of each filter and use them in the next iteration. This works for the FIR filters using the standard
[y,zf] = filter(b,a,X,zi).
However, I can't do that with Hband. How can I return an update of the Hband states from the filter function for further use? I assume that Hband(i).states has something to do with it, however it doesn't seem to change at all. It's my first time doing this and I'm not familiar with second order section IIR filter cascades etc., so any help would be highly appreciated.
Nemanja

Accepted Answer

Wayne King
Wayne King on 17 May 2012
After you design your filter, set the PersistentMemory property of the object to true.
d = fdesign.bandpass;
Hd = design(d,'cheby1');
Hd.PersistentMemory = true;
Hd
Now you see the states. Apply your filter to some data.
y = filter(Hd,randn(1024,1));
% view the states
Hd
  1 Comment
Nemanja
Nemanja on 18 May 2012
Hi Wayne,
thank you for the fast answer. So the
Hd.PersistentMemory = true; is similar to reserving memory for the object with new in C++? I'll let you know if it worked as soon as I try it out.
Nemanja

Sign in to comment.

More Answers (2)

Nemanja
Nemanja on 22 May 2012
It worked, thank you!

Nemanja
Nemanja on 22 May 2012
I have a new question regarding this issue. If I need to use the same bandpass on different signals, I have the problem that the same memory block is reserved for all of them - to clarify, I create several bandpass filters for the required bands. Since I need to use those on different signals I thought I could just replicate the filter object array, get a filter object matrix and use the bandpass filters in row n for signal n (each row has numBands filter objects). However, the same memory block is reserved for the filters in the different rows so that the states asociated with bandpass k in row n are the same as for bandpass k in any other row. Is there a way to avoid this - I set the PersistentMemory to false when I design the filter and run through all numSignals*numBands filter objects and set it to true and that doesn't work. I assume that if I create numSignals*numBands bandpass filters instead of numBands filters which are then replicated I won't have this problem. But this takes quite some time so I wanted to ask whether there is another way to deal with this.
Nemanja

Community Treasure Hunt

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

Start Hunting!