How to design a IIR highpass filter?
7 views (last 30 days)
Show older comments
I'm having trouble to design a 120th order highpass filter with cutoff frequency = 6kHz, and sampling frequency of 20kHz. Thank you in advance.
1 Comment
Star Strider
on 23 Oct 2024
A 120-order filter?
Fs = 2E+5;
n = 120;
Rp = 1;
Rs = 50;
Wp = 6E+3*2/Fs;
[z,p,k] = ellip(n, Rp, Rs, Wp, 'high');
[sos,g] = zp2sos(z,p,k);
figure
freqz(sos, 2^16, Fs)
You wiill have to do this yourself.
Good luck!
.
Answers (1)
Prasanna
on 23 Oct 2024
Hi Jimmy,
To design a highpass filter with specified cutoff frequency, you can use the ‘fir1’ function in MATLAB. To create the same, follow these steps:
- Define specifications of the filter and normalize the cutoff frequency with respect to the Nyquist frequency. Normalizing the cutoff frequency ensures that the filter design algorithms correctly interpret the frequency specifications relative to the sampling rate.
- Design the filter by using the ‘fir1’ function with the ‘high’ argument to specify that it is a high pass filter
A sample MATLAB code for the above is given as follows:
% Specifications
order = 120; % Filter order
cutoff_freq = 6000; % Cutoff frequency in Hz
sampling_freq = 20000; % Sampling frequency in Hz
% Normalize the cutoff frequency with respect to Nyquist frequency
nyquist_freq = sampling_freq / 2;
normalized_cutoff = cutoff_freq / nyquist_freq;
% Design the highpass filter using fir1
b = fir1(order, normalized_cutoff, 'high');
Higher order filters can sometimes be unstable, in which case replace them by using a lower order filter. You can also consider IIR filters with the ‘butter’, ‘cheby1’, or ‘ellip’ functions. For more information regarding the functions used, refer the following documentations:
- Fir1: https://www.mathworks.com/help/signal/ref/fir1.html
- Butterworth filter: https://www.mathworks.com/help/signal/ref/butter.html
- Chebyshev Type I filter: https://www.mathworks.com/help/signal/ref/cheby1.html
- Elliptic filter: https://www.mathworks.com/help/signal/ref/ellip.html
0 Comments
See Also
Categories
Find more on Filter Design in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!