Reducing Noise from Matlab Generated Square Wave - SNR 0dB

In summary: 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 correl
  • #1
guru
38
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
  • #2
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.).
 
  • #3
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.
 
  • #4
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?
 
  • #5
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-
 

1. What is SNR and how does it affect the square wave generated in Matlab?

SNR stands for Signal-to-Noise Ratio and it is a measure of the ratio of the signal power to the noise power. In the case of a square wave generated in Matlab, a lower SNR value of 0dB indicates a higher level of noise compared to the signal, resulting in a lower quality waveform.

2. What are the common sources of noise in a Matlab generated square wave?

The most common sources of noise in a Matlab generated square wave include quantization noise, truncation noise, and round-off noise. These noises are introduced during the digital-to-analog conversion process and can significantly affect the quality of the waveform.

3. How can I reduce noise in a Matlab generated square wave with an SNR of 0dB?

There are several techniques that can be used to reduce noise in a Matlab generated square wave with an SNR of 0dB. These include increasing the bit-depth of the digital signal, using a low-pass filter, and implementing dithering techniques to reduce quantization noise.

4. Is it possible to achieve a perfect square wave without any noise in Matlab?

No, it is not possible to achieve a perfect square wave without any noise in Matlab. This is because the digital-to-analog conversion process will always introduce some level of noise. However, by using the techniques mentioned in the previous answer, the noise can be significantly reduced to achieve a high-quality waveform.

5. Can I use a higher SNR value to reduce noise in a Matlab generated square wave?

Yes, increasing the SNR value can help reduce noise in a Matlab generated square wave. However, this will require a higher bit-depth and more advanced noise reduction techniques, which may also increase the complexity and cost of the system.

Similar threads

Replies
9
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
10K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
10K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
8K
Replies
1
Views
764
  • Electrical Engineering
Replies
6
Views
8K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • Programming and Computer Science
Replies
2
Views
1K
  • Electrical Engineering
Replies
2
Views
2K
Back
Top