Can anybody help me with an alternative function for DesignFilt and crossover filters. These functions work only with matlab 2016. it doesn't work in matlab 2013. What is the alternative function?
MATLAB: Designfilt and crossover filters
designfilt crossover filters
Related Solutions
I have absolutely no idea what ‘2.01’, ‘2.02’ and ‘2.03’mean.
Here is a prototype bandstop filter design that you can change to produce the filter you want:
Fs = 900; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
Wp = [48 52]/Fn; % Stopband Frequency (Normalised)
Ws = [0.9 1.1].*Wp; % Passband Frequency (Normalised)
Rp = 1; % Passband Ripple
Rs = 90; % Passband Ripple (Attenuation)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Elliptic Order Calculation
[z,p,k] = ellip(n,Rp,Rs,Wp,'stop'); % Elliptic Filter Design: Zero-Pole-Gain
[sos,g] = zp2sos(z,p,k); % Second-Order Section For Stability
figurefreqz(sos, 2^18, Fs) % Filter Bode Plot
set(subplot(2,1,1), 'XLim',[0 Fs/5]) % Optional
set(subplot(2,1,2), 'XLim',[0 Fs/5]) % Optional% signal_filt = filtfilt(sos, g, signal); % Filter Signal
Un-comment the filtfilt line to filter your signal.
You have to divide your passband and stopband frequencies by the Nyquist frequency to normalise them:
Fs = 1000; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
Wp = [10 495]/Fn; % Norrmalised Passband Frequencies
Ws = [5 499]/Fn; % Normalised Stopband Frequencies
Rp = 1; % Passband Ripple (dB)
Rs = 25; % Stopband Ripple (dB)
[n,Wn] = buttord(Wp, Ws, Rp, Rs); % Optimal Filter Order
[b,a] = butter(n, Wn); % Calculate Filter Coefficients
[sos,g] = tf2sos(b,a); % Convert To Second-Order Sections For Stability
figure(1)freqz(sos, 4096, Fs) % Filter Bode Plot
You cannot have any frequency exactly at zero or exactly at the Nyquist frequency, so I designed your passband to be close enough to them to be stable. In your filter, you can also use a high-pass design with a lower cutoff of 10 Hz, since your upper passband is at the Nyquist frequency. The passband and stopband ripple values are necessary to specify in the design but irrelevant to a Butterworth filter. These are acceptable values for most filter designs (for example Chebyshev) that require them.
You would use the ‘sos’ and ‘g’ variables in your actual filter:
filtered_signal = filtfilt(sos, g, signal);
(This design works well in R2016a and should also work in earlier releases.)
Best Answer