フィルターのクリア

I want to change Kaiser Window parameters

1 回表示 (過去 30 日間)
Zaref Li
Zaref Li 2024 年 1 月 5 日
回答済み: Hassaan 2024 年 1 月 16 日
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 件のコメント
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2024 年 1 月 5 日
編集済み: Sulaymon Eshkabilov 2024 年 1 月 5 日
kaiserbeta() is a function or what that is missing

サインインしてコメントする。

回答 (1 件)

Hassaan
Hassaan 2024 年 1 月 16 日
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.

カテゴリ

Help Center および File ExchangeMatched Filter and Ambiguity Function についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by