Calculate the stop band energy of a filter by its Power spectral density graph
2 次查看(过去 30 天)
显示 更早的评论
I want to find the stop band energy of a filter by its Power spectral density graph. Stop band energy is calculated with normalized total energy.
I can not find the command for it. Below is the correct code of a rectangular filter.
%% Rectangular Filter
Ts = 0.01; % sampling time
time = -20:0.01:20; % time axis
NFFT = 2048; % number of samples
freq = linspace(-0.5,0.5,NFFT); % frequency axis
ht_Rectangular = zeros(size(time));
%% In Time Domain
for n = 1:length(time)
if time(n)>=-0.5 && time(n)<=0.5
ht_Rectangular(n) = 1;
end
end
figure(1);
plot(time,ht_Rectangular);
xlabel('t/T_s');
ylabel('h(t)');
title('Impulse Response of Rectangular Filter');
grid on,
%% In Frequency Domain
Hf_Rectangular = fftshift(fft(ht_Rectangular,NFFT)); % FFT with FFTshift for both negative & positive frequencies
figure(2);
plot(freq, (Hf_Rectangular(1:length(freq)))/max(Hf_Rectangular));
xlabel('f/F');
ylabel('H(F)');
title('Frequency Response of Rectangular Filter');
grid on,
%% Power Spectral Density
[PSD_Rectangular, F_Rectangular] = periodogram (ht_Rectangular, [], length (ht_Rectangular));
figure(3);
plot (F_Rectangular, 10 * log10 (PSD_Rectangular));
xlabel('f/F');
ylabel('PSD (dB)');
title('Power Spectral Density of Rectangular Filter');
grid on,
0 个评论
回答(1 个)
Nitin Kapgate
2021-1-13
You can use the "bandpower" function to calculate the stop band energy from PSD as illustrated in this example.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Parametric Spectral Estimation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!