Dear fellows i am removing noise from( 3-200)HZ.

1 view (last 30 days)
Dear fellows i am removing noise from( 3-200)HZ ,but the problem is that after removing frequency i took IFFT of signal so that i can check the signal in time domain,but he problem is that my signal is so much different from my orginal signal in time domain.I want signal almost similar to my original signal which i have in my first figure.Can anyone help me to solve my problem and please check my mistake where i did in my code.
clc,close all,clear all
codn=70;
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]);
ook1.jpg
y = fftshift(fft(x2)/N);
z=abs(y);
figure(2)
plot(fvec,abs(y))
title('FFT')
xlabel('frequency')
ylabel('amplitude')
t.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')
d.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')
w.jpg
  1 Comment
Image Analyst
Image Analyst on 29 Oct 2019
Your original signal looks like a nice pulse train with no noise at all on it. Where is your signal with the noise?

Sign in to comment.

Answers (1)

Daniel M
Daniel M on 28 Oct 2019
Edited: Daniel M on 28 Oct 2019
Let me link back to the previous time you asked this question, so other contributors can see the solution already provided.
And again, I ask you, what do you want?
The output is a very nicely filtered signal. You haven't indicated how you would like to handle amplitudes outside the bounds [0,1].
  3 Comments
Daniel M
Daniel M on 29 Oct 2019
Edited: Daniel M on 29 Oct 2019
In the link, you were shown how to use a median filter to remove those high frequency components. Those components only exist because of the way you have filtered your data from 3-200 Hz, in a very sharp/abrupt method, leaving ringing. I also recommended you instead use filtfilt with a butterworth (or other) type of (lowpass) IIR filter.
It's hard to help people when they don't respond or try your suggestions.
If you want a signal that "looks like your original signal", then you probably don't want what you think you want. Filtering a square wave signal will not return to you another square wave signal.
Daniel M
Daniel M on 29 Oct 2019
And once again, I remind you to use ifftshift when you shift back into the time domain, not fftshift.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!