MATLAB Answers

0

Remove strong Noise in signal

Asked by Thiago Petersen on 19 Apr 2019
Latest activity Commented on by Thiago Petersen on 22 Apr 2019
Hello,
I am thinking if is possible to remove a very strong noise in a signal that i recorded. The idea is to remove the noise from the files and only plot the signal (like in the first five spikes). Is it possible to locate only the major spikes and so remove it? Other problem is that sometimes the minor spikes happens in the same times than major spikes (this happens in the 6th spike). Follow the data attached. I will appreciate any help. Thanks!
noisy.jpg

  2 Comments

Do you want to remove larger spike (amplitude) or clip its aplitude in certain range?
The idea is to remove all the spikes that have larger amplitude than the first 5 spikes (the minor ones)

Sign in to comment.

1 Answer

Answer by Image Analyst
on 20 Apr 2019

Try this:
% Get threshold based on first 5 points. It should be bigger than the tallest of those, say by 10% or whatever
threshold = max(signal(1:5)) * 1.10;
% Get "good" indexes - those with signal values less than the threshold.
goodIndexes = signal < threshold;
filteredSignal = signal(goodIndexes);

  1 Comment

Hi! Thanks for the reply, but it solves partially my problem. The problem in your solution is that the signal (minor spikes) and the noise (major spikes) will be affected. I only want to the bigger spikes be removed, not the smaller ones.
I was thinking to make a new vector with the noise inverted and add it in the same time that the noise occurs (using the indexes) to remove it. The noise has a fixed waveform, so maybe I could use the ginput to collect the noise data (like the .jpg attached), insert it to a vector and sum to the signal data. I tried to do it, but I got stuck after I got the noise shape.
You think this could work?
I will appreciate your reply.
mga = 2.5;
dist1 = 10000;
fs = 48828.125; % sample rate
time =[1/fs:1/fs:length(signal)/fs];
plot(time,signal)
hold on
lim1 = max(signal(1:dist1))*mga;
[t2,peakind]= findpeaks(signal,fs,'MinPeakProminence',lim1)
plot(peakind,t2,'or')
% to get the indexes of the noise
[peakValues, indexes] = findpeaks(signal,'MinPeakProminence',lim1)
% this is to get the noise shape
pause % so you can zoom to find a clear noise (bigger spike)
ind2 = ginput(2) % select start and end of the noise spike
ind21 = find(time<ind2(1));
ind21 = ind21(end);
ind22 = find(time<ind2(2));
ind22 = ind22(end);
s2 = signal(ind21:ind22);
ts2 = [1/fs:1/fs:length(s2)/fs];
is2 = s2*-1; %invert the noise shape

Sign in to comment.