problems with ifft of bandpass filtered white noise
Show older comments
I need to bandpass filter the white noise signal of 2 sec lenght and my teacher wants me to use fft() to go from time domain to frequency domain, where I can just give value of 0 to frequencies of non interest. And then using ifft() to go back to time domain. The problem is: when I convert back to time domain the amplitude of the last 0.8 sec of the signal is near 0. Someone can look at my code and finde a problem, please?

%% Generate white noise
Fs = 40000; % Sampling frequency
F = 1000; % center frequency
t = 0:1/Fs:2; % Time vector
L = length(t); % Signal length
X=wgn(L,1,0); % White noise at 0 dB
figure(1)
plot(t,X)
title('White noise')
xlabel('Time (sec)')
ylabel('X(t)')
%% Cenvert from time domain to frequensy domain
n = 2^nextpow2(L);
Y = fft(X,n);
f = Fs*(0:n-1)/n;
P = abs(Y/n);
figure(2)
plot(f,P)
title('White noise in Frequency Domain')
xlabel('Frequency (Hz)')
ylabel('|P(f)|')
%% Bandpass filtering 1 ocatve centered at 1 kHz
N=length(Y);
bw_low=round(N*F/(Fs*sqrt(2)));
bw_high=round(N*F*sqrt(2)/Fs);
bw_low_s=round((Fs-2*F+F/sqrt(2))*N/Fs);
bw_high_s=round((Fs-2*F+F*sqrt(2))*N/Fs);
Y(1:bw_low-1)=0;
Y(bw_high+1:bw_low_s-1)=0;
Y(bw_high_s+1:end)=0;
P_BP = abs(Y/n);
figure(3)
plot(f,P_BP)
title('Bandpass White noise in Frequency Domain')
xlabel('Frequency (Hz)')
ylabel('|P(f)|')
%% Convert from frequency domain to time domain
X_1 = ifft(Y,L);
figure(4)
plot(t,X_1);
title('1 octave White noise centered at 1 kHz')
xlabel('Time (sec)')
ylabel('X(t)')
%%
Accepted Answer
More Answers (0)
Categories
Find more on Vibration Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!