Frequency domain filtering in Matlab

In summary, the conversation discusses the implementation of cosine, Shepp-Logan, Hann/Hamming window filters in Matlab for Fourier domain filtering. These filters are defined by multiplying the ramp filter by the cosine function, sinc function, and Hann/Hamming windows respectively. The justification for using the parameter d is to adjust the cut-off frequency and prevent aliasing. There is an algorithm for calculating it accurately for each filter, using d=0.33 as the default value. However, for d=1, there may be an issue with units and normalization. The conversation also mentions using different normalization methods to obtain correct results.
  • #1
roam
1,271
12
I am trying to implement several filters in Matlab for Fourier domain filtering. They are the cosine, Shepp-Logan, and Hann/Hamming window filters. These filters are defined as multiplying the ramp filter by the cosine function, sinc function, and Hann/Hamming windows respectively.

This is how the responses of these filters should look like:

tiki-download_file.php?fileId=433&display.jpg

However, this is what I am getting:

filters.jpg


I have defined the filters exactly as they are defined in this Matlab function, with a parameter ##d## that stretches the filters:

Code:
w=linspace(0, 1, 181).'; % Frequency axis

d=0.33;

Hr = abs(w); % Ramp filter

H=Hr.* cos(w/(d)); % Cosine filter
H(H<0) = 0; 

H=Hr.* (sin(w/d)./(w/d)); % Shepp-Logan filter
H(H<0) = 0; 

H=Hr.* (1+cos(w./d)) / 2; % Hann filter
H(H<0) = 0; 

H=Hr.* (.54 + .46 * cos(w/d)); % Hamming filter
H(H<0) = 0;

For instance, if I change it to ##d=0.3##, the Hann/Hamming filters start to look correct. And at ##d=0.65##, the cosine filter looks more correct:

d3filter.jpg


So, what is the justification for using the parameter ##d##? And is there an algorithm for calculating it accurately for each filter?

Any explanation would be greatly appreciated.
 
Physics news on Phys.org
  • #2
What do you get for d=1? I am guessing it might have to do with normalization?
 
  • Like
Likes roam
  • #3
PhysicoRaj said:
What do you get for d=1? I am guessing it might have to do with normalization?
The second plot above is d=1. I suspect there is a degree/radian/frequency units issue.
 
  • Like
Likes PhysicoRaj and roam
  • #4
I tried to plot the graphs without the ##d## but instead using some kind of normalization. This is the combination that produced the correct results:

$$H=|\omega| \cos \left( \frac{\omega}{2 \pi} \right)$$

$$H=|\omega| \left( \frac{\sin \left( \frac{\omega}{2 \pi} \right)}{\left( \frac{\omega}{2 \pi} \right)} \right)$$

$$H = |\omega| \frac{1+\cos(\omega \pi)}{2}$$

$$H = |\omega| (0.54 + 0.46 \cos (\omega \pi))$$

Is there any reason why we need to divide the frequency in the first two by ##2 \pi##, but multiply it by ##\pi## in the Hann and Hamming window?

It was a trial and error approach, so I am not sure. :confused:
 
  • #5
d has to do with cut-off frequency I guess. It must be lower than Nyqvist frequency to prevent aliasing and d=0.33 means that it is only 33% of Nyqvist frequency.
 
  • #6
@roam You seem to be using Cos(ω/2π) on your calculations. The argument in a trig function should not be frequency (ω/2π). It should be in angular frequency (ω). This could be some of your problem.
 

1. What is frequency domain filtering in Matlab?

Frequency domain filtering in Matlab is a digital signal processing technique used to manipulate the frequency components of a signal. It involves converting the signal from the time domain to the frequency domain, applying a filter to the frequency components, and then converting the signal back to the time domain.

2. What are the benefits of using frequency domain filtering in Matlab?

Frequency domain filtering allows for precise manipulation of specific frequency components in a signal. This can be useful in removing noise, enhancing desired signals, and performing other signal processing tasks such as spectral analysis.

3. How do I apply a frequency domain filter in Matlab?

To apply a frequency domain filter in Matlab, you will need to use the FFT (Fast Fourier Transform) function to convert the signal from the time domain to the frequency domain. Then, you can use functions such as fftshift and ifft to manipulate the frequency components, and finally use the ifft function again to convert the signal back to the time domain.

4. Can I design my own frequency domain filter in Matlab?

Yes, Matlab allows for the design of custom frequency domain filters using functions such as freqz and fdesign. These functions allow for the specification of filter characteristics such as cutoff frequency and filter type, and can generate a filter that can be applied to a signal using the methods mentioned in question 3.

5. Are there any limitations to using frequency domain filtering in Matlab?

One limitation of frequency domain filtering in Matlab is that it requires the entire signal to be loaded into memory, which can be an issue for large signals. Additionally, the conversion from time domain to frequency domain can introduce errors, which may affect the accuracy of the filtering process.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
Replies
7
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
8K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Electrical Engineering
Replies
1
Views
2K
  • Electrical Engineering
Replies
20
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
11
Views
2K
Back
Top