Calculate the stop band energy of a filter by its Power spectral density graph

4 visualizzazioni (ultimi 30 giorni)
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,

Risposte (1)

Nitin Kapgate
Nitin Kapgate il 13 Gen 2021
You can use the "bandpower" function to calculate the stop band energy from PSD as illustrated in this example.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by