Borrar filtros
Borrar filtros

I want to change Kaiser Window parameters

1 visualización (últimos 30 días)
Zaref Li
Zaref Li el 5 de En. de 2024
Respondida: Hassaan el 16 de En. de 2024
Hello everyone,
I am designing ideal filter using Kaiser window. I give filter requirements :
I wrote this code. But how can I change the parameters?
A1 = 40; % Stopband attenuation in dB
A2 = 15; % Passband attenuation in dB
delta_w = 0.2 * pi; % Transition band width
omega_c1 = 0.3 * pi; % Lower critical frequency
omega_c2 = 0.5 * pi; % Upper critical frequency
% Design Filter using Kaiser Window
N = ceil((A1 - 7.95) / (2.285 * delta_w)); % Estimate filter order
beta = kaiserbeta(A2); % Calculate Kaiser window beta parameter
h = fir1(N, [omega_c1, omega_c2], 'bandpass', kaiser(N+1, beta)); % Design filter
% Impulse Response Plot
figure;
stem(h);
title('Impulse Response h[n]');
xlabel('n');
ylabel('h[n]');
% Frequency Response Plot
[H, w] = freqz(h, 1, 1024); % Calculate frequency response
H_mag = 20*log10(abs(H)); % Magnitude in dB
figure;
plot(w/pi, H_mag); % Plot frequency response
title('Magnitude Frequency Response');
xlabel('Normalized Frequency (\omega/\pi)');
ylabel('Magnitude (dB)');
% Check gains at critical frequencies
omega = [omega_c1, omega_c2];
[H_c, ~] = freqz(h, 1, omega);
gains = 20*log10(abs(H_c)); % Gains in dB
disp('Gains at critical frequencies:');
disp(gains);
  1 comentario
Sulaymon Eshkabilov
Sulaymon Eshkabilov el 5 de En. de 2024
Editada: Sulaymon Eshkabilov el 5 de En. de 2024
kaiserbeta() is a function or what that is missing

Iniciar sesión para comentar.

Respuestas (1)

Hassaan
Hassaan el 16 de En. de 2024
A1 = 60; % New stopband attenuation in dB
A2 = 20; % New passband attenuation in dB
delta_w = 0.15; % New normalized transition band width
omega_c1 = 0.25; % New normalized lower critical frequency
omega_c2 = 0.45; % New normalized upper critical frequency
% Estimate filter order and beta using kaiserord
[N, beta] = kaiserord([omega_c1, omega_c2], [0, 1], [10^(-A2/20), 10^(-A1/20)]);
% Design Filter using Kaiser Window
h = fir1(N, [omega_c1, omega_c2], kaiser(N+1, beta)); % Design filter
% Impulse Response Plot
figure;
stem(h);
title('Impulse Response h[n]');
xlabel('n');
ylabel('h[n]');
% Frequency Response Plot
[H, w] = freqz(h, 1, 1024); % Calculate frequency response
H_mag = 20*log10(abs(H)); % Magnitude in dB
figure;
plot(w/pi, H_mag); % Plot frequency response
title('Magnitude Frequency Response');
xlabel('Normalized Frequency (\omega/\pi)');
ylabel('Magnitude (dB)');
% Check gains at critical frequencies
omega = [omega_c1, omega_c2];
[H_c, ~] = freqz(h, 1, omega*pi);
gains = 20*log10(abs(H_c)); % Gains in dB
disp('Gains at critical frequencies:');
Gains at critical frequencies:
disp(gains);
-5.5498 -5.5691
I've removed the pi factor from the critical frequencies omega_c1 and omega_c2 to normalize them correctly to the range [0, 1]. This should resolve the error, and your Kaiser window-based filter will be designed based on the updated filter specifications with normalized frequencies.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.

Categorías

Más información sobre Matched Filter and Ambiguity Function 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!

Translated by