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.

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

1 Comment

Dear daniel,
Thanks for responding me,actually i am working on visible light communicatio.I have to reduce flicker which come in range which i have removed in frequency domain.Now in time domain signal which is shown i have to mitigate noise as much as i can.
Best regards,
Imran Khan

Sign in to comment.

 Accepted 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]);

3 Comments

Dear thanks for assisting me,but problem is that in your filter at output results signal exist in negative amplitutde also,but in visible light communication we do not send signal having negative amplitude.Second thing please tell you make dc component zero what is the purpose of making zero.Fvec you start from 0 but in my FFT fvec start from negative.
Thankyou for assisting me.
1. Take the absolute value of the signal to remove negative amplitudes. Or you can clip them at zero. It's not clear how you want to handle them.
2. He made the DC component zero in the same way you did with x2 = x-0.5, except using mean(x) is more robust.
3. His frequencies started from zero because he did not choose to fftshift the signal. Both methods are equivalent.
Daniel M is right, the changes I made were like little suggestions about how to improve/shorter your code, but aside from the mean they are equivalent to what you wrote. I got some negative values because the dc component is a little more than 0.5, so I got a shiffted result which is actually a better representation of the signal without the dc component because of the use of mean(), and the only reason I did it was because you wrote it in your initial code. For you to retain the same signal structure and still have positive values you can simply don't remove the dc or shift the result signal to have a determinated minimum, so you have a signal structure independent of the actual dc component. Shift the minimum to zero, for example, would be something like that:
x2 = x2-min(x2);
If this is still not what you need you should be more specific about your problem and what you actually want.

Sign in to comment.

More Answers (0)

Categories

Find more on Detection, Range and Doppler Estimation 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!