MATLAB: I have removed frequency from (3-200)HZ from FFT signal.Now i want to remove noise from last figure which is in time domain so that i can transmit signal.Thanks in advance.

remove noise

clc,close all,clear all
codn=70;
% fc=6e+3;
fs=3600;
bode=10;
code=round(rand(1,codn));
code_len=round(1/bode/(1/fs))
for ii=1:codn
x((ii-1)*code_len+1:code_len*ii)=code(ii);
end
x2 = x-(1/2) % get rid of most of the dc peak
% set up time and frequency arrays
N = length(x);
delt = 1/fs;
delf = fs/N
tvec = (1:N)*delt
fvec = (-N/2:N/2-1)*delf ; % shifted frequency array
figure(1)
plot(tvec,x2(1,:)+0.5)
title('orignal baseband')
xlabel('time');
ylabel('amplitude')
ylim([-1 1.5]);
abc.jpg
y = fftshift(fft(x2)/N);
z=abs(y);
figure(2)
plot(fvec,abs(y))
title('FFT')
xlabel('frequency')
ylabel('amplitude')
abc1.jpg
figure(3)
z=y;
z(abs(fvec)>=3 & abs(fvec)<=200)=0
plot(fvec,abs(z))
xlabel('frequency removed from 3 to 200 HZ');
ylabel('amplitude')
untitled.jpg
figure(4)
zf=fftshift(z)*N;
zifft=ifft(zf)+0.5
plot(tvec,abs(zifft))
ylim([-1 1.5])
title('recovered signal')
xlabel('time');
ylabel('amplitude')
untitled1.jpg

Best Answer

For your signal a median filter may work fine enough.
clc,close all,clear all
codn=70;
% fc=6e+3;
fs=3600;
bode=10;
code=round(rand(1,codn));
code_len=round(1/bode/(1/fs));
for ii=1:codn
x((ii-1)*code_len+1:code_len*ii)=code(ii);
end
% set up time and frequency arrays
N = length(x);
delt = 1/fs;
delf = fs/N;
tvec = (1:N)*delt;
fvec = [0:N-1]*delf ; % frequency array
subplot(3,1,1)
plot(tvec,x(1,:))
title('orignal baseband')
xlabel('time');
ylabel('amplitude')
ylim([-1 1.5]);
% Filter x
xFFT = fft(x-mean(x)); % In this way you remove all the dc component
xFFT(abs(fvec)>=3 & abs(fvec)<=200) = 0;
x2 = ifft(xFFT,'symmetric');
subplot(3,1,2)
plot(tvec,x2(1,:))
title('Noise Signal')
xlabel('time');
ylabel('amplitude')
ylim([-1 1.5]);
x2 = medfilt1(x2,50); % Filter with median filter
subplot(3,1,3)
plot(tvec,x2(1,:))
title('Filtered Signal with median filter')
xlabel('time');
ylabel('amplitude')
ylim([-1 1.5]);
Related Question