필터 지우기
필터 지우기

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 CenterFile Exchange에서 Matched 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