4

I have a signal/vector with high amplitude white gaussian noise and I'm trying to get a binary signal (0 or 1). The sampling frequency is 10Hz.

I applied a simple 2nd order Butterworth filter in MATLAB as follows;

   x=sig_bruit_BB1;
   [b,a]=butter(2,0.1,'low');
   y = filter(b,a,x);
   plot(x)
   subplot(3,1,2)
   plot(y)
   for i=1:1:1820
       x=y(1,i);
       if (x<0.5)
           code(1,i)=0;
       else
           code(1,i)=1;
       end
   end
   subplot(3,1,3);
   plot(code)

As you can see, I did a for loop assuming that any signals smaller than 0.5 is equal to 0 and greater equals to 1.

Can somebody verify if this method is applicable to obtain a binary signal ?

Thanks.

user1948421
  • 41
  • 1
  • 2

2 Answers2

3

This method certainly works (without seeing the signal it is difficult to judge whether it's the best possible approach, though). However, there is a much easier way for thresholding - instead of the loop, you can simply write

code = x > 0.5;
Jonas
  • 74,690
  • 10
  • 137
  • 177
0

I would suggest to implement one more step to make it a yet more robust way of thresholding:

  • if the signal is at 0, the threshold should be 0.5 + noise_amplitude (let's say 0.6 0.7)
  • if the signal is at 1, the threshold should be 0.5 - noise_amplitude (let's say 0.4 0.3)

In this way you won't risk to have several jumps from 0 to 1 to 0 when the signal is jumping around the single threshold (of 0.5) because of noise.

msysmilu
  • 2,015
  • 23
  • 24