MATLAB: Cascade of discrete filters in MATLAB

filterMATLAB

Hello everyone. I'm trying to make a band-reject filter but I can't put 2 filters in cascade.
This:
lp = fir1(100, 0.77, 'low', rectwin(101));
hp = fir1(100, 0.83, 'high', rectwin(101));
dfilt.cascade(lp,hp)
gives the following error: Error using dfilt.cascade (line 43) Numeric section in a cascade must be a nonempty scalar.
Thanks!

Best Answer

To use dfilt.cascade, you have to create the correct dfilt filter objects from your filters first:
lp = fir1(100, 0.77, 'low', rectwin(101));
hp = fir1(100, 0.83, 'high', rectwin(101));
lpf = dfilt.df2(lp,1);
hpf = dfilt.df2(hp,1);
ntch = dfilt.cascade(lpf,hpf);
figure(1)
freqz(ntch)
You may want to reconsider your filter designs.