MATLAB Reducing Noise from Matlab Generated Square Wave - SNR 0dB

AI Thread Summary
The discussion focuses on designing a filter to reduce noise in a square wave generated in Matlab, with an initial signal-to-noise ratio (SNR) of 0 dB. A Chebyshev or elliptical filter is suggested for optimal noise reduction, with ripples in the passband tailored to match the square wave's harmonics. To determine the cutoff frequency, it is recommended to set it just above the fundamental frequency of the square wave. For a more advanced approach, a digital correlator design is proposed, which involves using a shift register to correlate the noisy input with a known square wave pattern. This method enhances noise rejection and can significantly improve SNR, especially with sufficient samples per cycle. The entire process can be implemented in Matlab for practical application.
guru
Messages
38
Reaction score
0
I posted the details of myquestions earlier but no help. Maybe I need to rephrase it.
I basically generated a square wave and added noise to it using Matlab.
The question is how do I design a filter to reduce as much noise as possible to retain most of the square wave. The SNR is OdB.

Thanks in advance
 
Physics news on Phys.org
Sounds like a Cheby filter with ripples in the passband (or an elliptical with ripples everywhere) would work the best, with the ripples matching the spectra of the square wave (fundamental, 3rd harmonic, etc.).
 
berkeman said:
Sounds like a Cheby filter with ripples in the passband (or an elliptical with ripples everywhere) would work the best, with the ripples matching the spectra of the square wave (fundamental, 3rd harmonic, etc.).

thanks for the help!:smile:
How do I determine the cutoff (corner) frequency to use given the frequency of the square wave and the sampling frequency.
 
guru said:
thanks for the help!:smile:
How do I determine the cutoff (corner) frequency to use given the frequency of the square wave and the sampling frequency.
If you want to keep it simple, just use the fundamental of the square wave, and put the cutoff right above that. A little fancier is what I was mentioning, to match a Cheby/elliptical filter's ripples to the 1/f rollof of the square wave's harmonics. The best solution, though, would be to do a correlation with a square wave of the same frequency. Do you always know the frequency of the original square wave?
 
berkeman said:
If you want to keep it simple, just use the fundamental of the square wave, and put the cutoff right above that. A little fancier is what I was mentioning, to match a Cheby/elliptical filter's ripples to the 1/f rollof of the square wave's harmonics. The best solution, though, would be to do a correlation with a square wave of the same frequency. Do you always know the frequency of the original square wave?
Edit -- I think a straight digital correlator design would give you the best results, if you know what the frequency of the original signal is. A digital correlator is where you have a shift register that you feed your input digitized signal into one end, and at each sample clock tick, you shift the data through the ganged registers. For each sample clock tick, you multiply each register value by some coefficient, and take the overall sum of the multiplications as the correlator output for that clock tick. To correlate against a bipolar square wave, for example, the coefficients for the first half of the ganged registers would be something like +1, and for the second half they would all be -1. The correlator is one period long for the square wave, measured in sample clock ticks.

So when you feed in your bipolar square wave plus noise, the output of the correlator will be +A (A=amplitude of the input signal) when the input signal lines up with the square wave coefficients, and -A when it lines up opposite of the coefficients. The correlator output is not a square wave -- instead it has peaks where the correlation is max and min, and zero crossings between these peaks. To convert the correlator output back to a square wave, use the A number and the zero crossings to take your best guess at the original signal. You will get very good noise rejection by using a correlator, especially if you have lots of samples per cycle, and as many bits per sample as possible. You should be able to get well below a 0dB SNR with a good correlator design. You can do this all in MatLab, so try it out! -Mike-
 

Similar threads

Back
Top