0% found this document useful (0 votes)
20 views

MATLAB program to design a digital high

This MATLAB program designs a digital high-pass FIR filter using a Hamming window with specified passband and stopband frequencies. It estimates the filter order using the Kaiser formula and computes the ideal impulse response for the filter. The program also plots the impulse response and magnitude response of the filter.

Uploaded by

Sai samarth Kh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

MATLAB program to design a digital high

This MATLAB program designs a digital high-pass FIR filter using a Hamming window with specified passband and stopband frequencies. It estimates the filter order using the Kaiser formula and computes the ideal impulse response for the filter. The program also plots the impulse response and magnitude response of the filter.

Uploaded by

Sai samarth Kh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

% MATLAB program to design a digital high-pass FIR filter using a Hamming window

% Specifications

fp = 6000; % Passband edge frequency in Hz

fs = 3000; % Stopband edge frequency in Hz

f_sampling = 8000; % Sampling frequency in Hz

attenuation_stopband = 21; % Minimum stopband attenuation in dB

% Normalized frequencies

wp = 2 * pi * fp / f_sampling; % Passband edge (rad/sample)

ws = 2 * pi * fs / f_sampling; % Stopband edge (rad/sample)

% Filter order estimation using Kaiser formula (approximation)

trans_bandwidth = abs(wp - ws) / (2 * pi); % Transition width (Hz)

delta_f = trans_bandwidth * f_sampling; % Transition width in Hz

A = attenuation_stopband; % Minimum attenuation

if A <= 21

beta = 0;

elseif A <= 50

beta = 0.5842 * (A - 21)^0.4 + 0.07886 * (A - 21);

else

beta = 0.1102 * (A - 8.7);

end

N = ceil((A - 8) / (2.285 * delta_f * pi)); % Filter order

if mod(N, 2) == 0

N = N + 1; % Ensure filter order is odd

end

% Ideal impulse response of a high-pass filter

n = -(N-1)/2 : (N-1)/2;

h = -sin(ws * n) ./ (pi * n); % sinc function for high-pass


h((N-1)/2 + 1) = 1 - ws / pi; % Correct the middle term

% Apply the Hamming window

window = hamming(N)';

h = h .* window;

% Frequency response of the filter

[H, f] = freqz(h, 1, 1024, f_sampling);

% Plot the results

figure;

subplot(2, 1, 1);

stem(n, h);

title('Impulse Response of the High-Pass FIR Filter');

xlabel('n');

ylabel('h[n]');

grid on;

subplot(2, 1, 2);

plot(f, 20*log10(abs(H)));

title('Magnitude Response of the High-Pass FIR Filter');

xlabel('Frequency (Hz)');

ylabel('Magnitude (dB)');

grid on;

You might also like