I didn't see Robert's post before writing my response, but I'll concede that his correlation approach is better than the comb filter I just proposed. Sort of depends what you mean by "a filter".

Mark

From: m...@yahoogroups.com [mailto:m...@yahoogroups.com] On Behalf Of r...@gmail.com
Sent: Tuesday, December 06, 2005 7:59 AM
To: m...@yahoogroups.com
Subject: [matlab] Re: Filtering Guassian noise with Matlab

On 12/3/05, tu5752 <pastor1984@past...> wrote:
>
> Hello all,
> I'm generating a 1 kHz square wave and adding Guassian noise to obtain
> a SNR of 0 dB (using Matlab6.5). The task is to design a filter that
> will filter out as much noise as possible from the square wave plus
> noise signal.
> The sampling frequency is 100kHz.
> Noise signal: 100.0*randn(1, length(t))
> Square wave: 100*square(2*pi*1000*t)
> What else do I need to know in order to design this filter using
> Butterworth or Chebyshev I or any filter? How do I determine the cut-
> off frequency for my filter?
> The MATLAB function filter(B,A,x) will be used for the time-domain
> filtering operation.
> I've started out by considering the frequency characteristics of each
> signal, but don't know how that will help in the design process.
> Any help will be greatly appreciated.
> Thanks

If you know what signal you are looking for, you should always use "matched filtering", which is essentially correlation. Generate another 1kHz square wave and convolve that with your square wave+noise signal.

In the real world I would probably consider using FFT-based correlation, but in MATLAB it may not matter, especially for short sequences.

Cheers,
Robert

 **************************************************************** The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to D...@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them. Thank you.

You're restricting your approach to low-pass filters? What about a series of narrow bandpass filters (ie, a comb filter) that only lets through the actual frequencies present in a 1 KHz square wave? One bandpass around 1 kHz, one around 3 kHz (no even harmonics in a square wave), then 5, 7 9 kHz, etc. This is essentially the "matched filter" approach, where the impulse response of the filter matches the known signal to be recovered from noise, and hence the frequency response of the filter matches the spectrum of the known signal. The more you know (and use) about the desired signal, the more noise you can eliminate.

Mark Egler

From: m...@yahoogroups.com [mailto:m...@yahoogroups.com] On Behalf Of Nandan Das
Sent: Monday, December 05, 2005 8:59 AM
To: tu5752
Cc: m...@yahoogroups.com
Subject: Re: [matlab] Filtering Guassian noise with Matlab

well...one way to approach this might be to think along the following
lines...your noise is AWGN and so its spectrum is flat across all
frequencies while your signal's frequency content falls off as you go out in
frequency.  Specifically, your signal is a sq wave and so its spectrum is a
sinc function.  So when you filter, you would filter out the higher
frequencies more aggressively since your signal doesnt have as much high
frequencies.  Obviously, if you do this,  you will kill some of your signal
-- so your filter cut-off frequency will trade off on how much noise you
kill vs how much signal you kill (more noise you kill, more signal will also
get killed as a result).  So play around with that cut-off frequency, and
see the results -- pick something that looks good.

You can also write out equations to find the optimal cut-off point and that
shouldn't be too hard to do either.

Nandan

On 12/3/05, tu5752 <p...@yahoo.com> wrote:
>
> Hello all,
> I'm generating a 1 kHz square wave and adding Guassian noise to obtain
> a SNR of 0 dB (using Matlab6.5). The task is to design a filter that
> will filter out as much noise as possible from the square wave plus
> noise signal.
> The sampling frequency is 100kHz.
> Noise signal: 100.0*randn(1, length(t))
> Square wave: 100*square(2*pi*1000*t)
> What else do I need to know in order to design this filter using
> Butterworth or Chebyshev I or any filter? How do I determine the cut-
> off frequency for my filter?
> The MATLAB function filter(B,A,x) will be used for the time-domain
> filtering operation.
> I've started out by considering the frequency characteristics of each
> signal, but don't know how that will help in the design process.
> Any help will be greatly appreciated.
> Thanks
 **************************************************************** The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to D...@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them. Thank you.

On 12/3/05, tu5752 <pastor1984@past...> wrote:
>
> Hello all,
> I'm generating a 1 kHz square wave and adding Guassian noise to obtain
> a SNR of 0 dB (using Matlab6.5). The task is to design a filter that
> will filter out as much noise as possible from the square wave plus
> noise signal.
> The sampling frequency is 100kHz.
> Noise signal: 100.0*randn(1, length(t))
> Square wave: 100*square(2*pi*1000*t)
> What else do I need to know in order to design this filter using
> Butterworth or Chebyshev I or any filter? How do I determine the cut-
> off frequency for my filter?
> The MATLAB function filter(B,A,x) will be used for the time-domain
> filtering operation.
> I've started out by considering the frequency characteristics of each
> signal, but don't know how that will help in the design process.
> Any help will be greatly appreciated.
> Thanks

If you know what signal you are looking for, you should always use "matched filtering", which is essentially correlation. Generate another 1kHz square wave and convolve that with your square wave+noise signal.

In the real world I would probably consider using FFT-based correlation, but in MATLAB it may not matter, especially for short sequences.

Cheers,
Robert

Hi

I am trying to design a low pass FIR filter with 4096 coefficients and transition band covers from 10kHz to 1MHz. Is there any chance I can do this coz normally with an order above 1000, the transition band is really really small.

Cheers
Trung

well...one way to approach this might be to think along the following
lines...your noise is AWGN and so its spectrum is flat across all
frequencies while your signal's frequency content falls off as you go out in
frequency. Specifically, your signal is a sq wave and so its spectrum is a
sinc function. So when you filter, you would filter out the higher
frequencies more aggressively since your signal doesnt have as much high
frequencies. Obviously, if you do this, you will kill some of your signal
-- so your filter cut-off frequency will trade off on how much noise you
kill vs how much signal you kill (more noise you kill, more signal will also
get killed as a result). So play around with that cut-off frequency, and
see the results -- pick something that looks good.

You can also write out equations to find the optimal cut-off point and that
shouldn't be too hard to do either.

Nandan

On 12/3/05, tu5752 <pastor1984@past...> wrote:
>
> Hello all,
> I'm generating a 1 kHz square wave and adding Guassian noise to obtain
> a SNR of 0 dB (using Matlab6.5). The task is to design a filter that
> will filter out as much noise as possible from the square wave plus
> noise signal.
> The sampling frequency is 100kHz.
> Noise signal: 100.0*randn(1, length(t))
> Square wave: 100*square(2*pi*1000*t)
> What else do I need to know in order to design this filter using
> Butterworth or Chebyshev I or any filter? How do I determine the cut-
> off frequency for my filter?
> The MATLAB function filter(B,A,x) will be used for the time-domain
> filtering operation.
> I've started out by considering the frequency characteristics of each
> signal, but don't know how that will help in the design process.
> Any help will be greatly appreciated.
> Thanks

Hello all,
I'm generating a 1 kHz square wave and adding Guassian noise to obtain
a SNR of 0 dB (using Matlab6.5). The task is to design a filter that
will filter out as much noise as possible from the square wave plus
noise signal.
The sampling frequency is 100kHz.
Noise signal: 100.0*randn(1, length(t))
Square wave: 100*square(2*pi*1000*t)
What else do I need to know in order to design this filter using
Butterworth or Chebyshev I or any filter? How do I determine the cut-
off frequency for my filter?
The MATLAB function filter(B,A,x) will be used for the time-domain
filtering operation.
I've started out by considering the frequency characteristics of each
signal, but don't know how that will help in the design process.
Any help will be greatly appreciated.
Thanks