Can 'cascade' be used on bandstop filters created with 'designfilt'?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Anne Bennett
el 9 de Jul. de 2019
Comentada: Star Strider
el 10 de Jul. de 2019
I'm having issues using 'cascade' on some 'bandstopfir' filters I created using 'designfilt'. Does cascade not support bandstopfir filters created this way? The error says "cascades must be of discrete-time filter objects." Mine seem to be 'digitalFilters' - is that different? The list of supported objects is unfamiliar to me- are these older filter types prior to designfilt?
clear; clc;
Fs = .25;
Apass1 = 2; % First Passband Ripple (dB)
Astop = 50; % Stopband Attenuation (dB)
Apass2 = 2; % Second Passband Ripple (dB)
% first notch - Hd_1
Fpass1 = 1E-3; % First Passband Frequency
Fstop1 = 1.1E-3; % First Stopband Frequency
Fstop2 = 1.2E-3; % Second Stopband Frequency
Fpass2 = 1.3E-3; % Second Passband Frequency
Hd_1 = designfilt('bandstopfir', 'PassbandFrequency1', Fpass1, ...
'StopbandFrequency1', Fstop1, 'StopbandFrequency2', Fstop2, ...
'PassbandFrequency2', Fpass2, 'PassbandRipple1', Apass1, ...
'StopbandAttenuation', Astop, 'PassbandRipple2', Apass2, ...
'SampleRate', Fs);
% second notch - Hd_2
Fpass1 = 2.15E-3; % First Passband Frequency
Fstop1 = 2.25E-3; % First Stopband Frequency
Fstop2 = 2.45E-3; % Second Stopband Frequency
Fpass2 = 2.55E-3; % Second Passband Frequency
Hd_2 = designfilt('bandstopfir', 'PassbandFrequency1', Fpass1, ...
'StopbandFrequency1', Fstop1, 'StopbandFrequency2', Fstop2, ...
'PassbandFrequency2', Fpass2, 'PassbandRipple1', Apass1, ...
'StopbandAttenuation', Astop, 'PassbandRipple2', Apass2, ...
'SampleRate', Fs);
Hd_all = cascade(Hd_1, Hd_2);
0 comentarios
Respuesta aceptada
Star Strider
el 9 de Jul. de 2019
If you want to design a filter with multiple stopbands, it is likely easier to do this with a FIR filter.
For example:
Fs = 1000; % Sampling Frequency (Hz)
fcuts = [56 58 62 64 116 118 122 124 176 178 182 184]; % Frequencies
mags = [1 0 1 0 1 0 1]; % Passbands & Stopbands
devs = [0.05 0.01 0.05 0.01 0.05 0.01 0.05]; % Tolerances
[n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,Fs); % Kaiser Window FIR Specification
n = n + rem(n,2);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale'); % Filter Realisation
figure
freqz(hh,1,2^14,Fs)
set(subplot(2,1,1), 'XLim',[0 200]); % Zoom Frequency Axis
set(subplot(2,1,2), 'XLim',[0 200]); % Zoom Frequency Axis
FIR filters are not the most computationally efficient (this one has a length of 1119) however that they lack in efficiency they make up for in ease-of-design, especially for more complicated filters. This one has a linear phase characteristic, so you can use filter with it. (You can also use filtfilt, however that may not be necessary.) See the documentation for the various functions to understand how they work.
5 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Digital Filter Design en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!