How to design a IIR highpass filter?

7 views (last 30 days)
Jimmy
Jimmy on 16 Dec 2014
Commented: Star Strider on 23 Oct 2024
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
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');
Error using ellipap2 (line 39)
The filter order is too large. Use a smaller value.

Error in ellipap (line 43)
[z,p,H0] = ellipap2(n,rp,rs);

Error in ellip (line 42)
[z,p,k] = ellipap(n, Rp, Rs);
[sos,g] = zp2sos(z,p,k);
figure
freqz(sos, 2^16, Fs)
You wiill have to do this yourself.
Good luck!
.

Sign in to comment.

Answers (1)

Prasanna
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:

Community Treasure Hunt

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

Start Hunting!