Question: I've got a signal generator sending a sine wave to a PCB (X3). I closed jumper 19 so I measure D10, a GF1M diode. I measured the voltage over test point 16 (TP16) and the voltage over TP18. I get the following image on an oscilloscope. As expected we see that the voltage over TP16 is rectified (red CH2). The voltage over TP18 is an asymmetric sine wave (blue CH1). The width of the parts under 0 is smaller than the width of the parts above 0, but I don't understand why this is the case.

[![The electric circuit](https://i.stack.imgur.com/UrYMA.png)](https://i.stack.imgur.com/UrYMA.png)
[![The image on the oscilloscope](https://i.stack.imgur.com/edJiY.png)](https://i.stack.imgur.com/edJiY.png)

Answer: 
So what you are after is filtering. However, you are in a really good position as you have the complete set of data and do not need to perform "real time" filtering.

"real time" filtering using FIR and IIR are good but introduce errors as they are causal and these errors are typically gain and phase related.

With the complete dataset a range of "offline" post-processing methods are available to you which you would not be able to fully realise in real-time.

1. filtfilt.
This type of filtering filters forward and reverse to mitigate the phase shift that filters typically introduce:
<https://www.mathworks.com/help/signal/ref/filtfilt.html>
2. Savitzky-Golay Filters
An advanced weighted least squares tracking filter which is extremely effective at extracting the underlying characteristics by providing lower significant on transient type effects.
<https://www.mathworks.com/help/signal/ref/sgolayfilt.html>
3. Kalman filter
an acausal type filter using "look ahead" to extract the true underlying trend
<https://www.mathworks.com/help/control/ug/kalman-filtering.html>
4. perfect Sinc filter
A sinc waveform which matches the length of the complete data is a true "brick wall" filter
<https://www.mathworks.com/matlabcentral/fileexchange/42956-sinc-filter>

My personal favorite is the SavGol filter

```
t= linspace(0,1e-3,10000);
y = zeros(10000,1);
y(t> 100e-6 & t < 300e-6) = 10;
y = y + rand(10000,1);

Ysav = sgolayfilt(y, 5, 9);
Y1stord = lowpass(y,1000,1/t(2));

figure;
plot(t,y);
hold;
plot(t,Ysav);
plot(t,Y1stord)

legend('raw data','SavGol filter','1st order LPF');

```

Basically you want filtering but you do not need to restrict yourself to the classic LPF (FIR,IIRC, R-C type filtering) as you have the complete dataset and thus more opportunities available

[![enter image description here](https://i.stack.imgur.com/JX8oC.png)](https://i.stack.imgur.com/JX8oC.png)
These "small oscillations" that you `refer to as noise` look suspiciously similar to **quantization noise**. If this is the case, consider a revision of your data acquisition setup. You may well be able to significantly reduce the amplitude of these "small oscillation" by simply increasing your ADC's resolution (like bit depth), signal amplifier gain or whatever serves to decrease the volt per level parameter. Even if the data acquisition setup is outside your control, knowing the origin of the unwanted distortions that measurement adds to your signal greatly helps in designing the noise suppression procedures like filtering or data fitting.