# Question about Fourier transformation in Matlab

• MATLAB
• Frank Einstein
In summary, the individual is trying to use the Fourier transform to calculate a band-pass filter for a vector with 660 components representing months. They are looking for a periodicity between 3 and 7 years and are attempting to remove all coefficients except those between the 36th and 84th component. However, they are obtaining unexpected results and are seeking help to determine where they went wrong. Suggestions are made to adjust the code and to consider using time series analysis.
Frank Einstein
Hello everybody.

I am triying to calculate a band-pass filter using the Fourier transform.
I have a vector with 660 compomponents; one for each month. I am looking for a phenomenon which has a periodicity between 3 and 7 years (it's el niño, on the souhtern pacific ocean). I want to make zero all the coefficients of the Fourier transform except the ones which are in between 3 and 7 years. I have tried to remove all of the coefficients which are between the 36th (12*3) and 84th (12*7). Then, I proceed to do the same thing in the other half of the series to mantain simmetry.

But once I make the inverse Fourier transform and I plot it, the results don't match whith what I want.

Can someone tell me where is my faliure?Code used:
niniofourier=fft(ninios);

for i=1:35
niniofourierb(i)=0;
end

for i=85:330
niniofourierb(i)=0;
end

for i=36:84
niniofourierb(i)=niniofourier(i);
end

for i=331:576
niniofourierb(i)=0;
end

for i=577:624
niniofourierb(i)=niniofourier(i);
end

for i=625:660
niniofourierb(i)=0;
end

niniosi=ifft(niniofourierb);
figure(4)
plot (niniosi)

You're selecting the wrong part of the DFT. You don't want coefficients 36 through 84.

You have 660 months worth of samples, so ##X_k## (for ##k=0, 1, \dots, 330##) corresponds to a cycle that has an angular frequency of ##k\omega_0## where ##\omega_0=2\pi/660\text{ rad/month}##. What you want to do is determine the range of ##k## that corresponds to angular frequencies between ##2\pi/36\text{ rad/month}## and ##2\pi/84\text{ rad/month}##.

Frank Einstein
vela said:
You're selecting the wrong part of the DFT. You don't want coefficients 36 through 84.

You have 660 months worth of samples, so ##X_k## (for ##k=0, 1, \dots, 330##) corresponds to a cycle that has an angular frequency of ##k\omega_0## where ##\omega_0=2\pi/660\text{ rad/month}##. What you want to do is determine the range of ##k## that corresponds to angular frequencies between ##2\pi/36\text{ rad/month}## and ##2\pi/84\text{ rad/month}##.

Thank you very much; I am using now this code:
for i=1:660
if (i-1)/660<pi/18
if (i-1)/660> pi/42
niniofourierb(i)=niniofourier(i);
else
niniofourierb(i)=0;
end
else
niniofourierb(i)=0;
end
end
niniosi=ifft(niniofourierb);
figure(4)
plot (niniosi)

But it seems like I still got it wrong. I am obtaining something which makes no sense

I have done the same filter using a low pass filter and I obtain reasonalbe results.

I have no idea what that plot is supposed to represent.

Don't forget that like before you also have to take care of the other half of the spectrum.

vela said:
I have no idea what that plot is supposed to represent.

Don't forget that like before you also have to take care of the other half of the spectrum.
I have plotted the inverse Fourier transform of the series in which all the coefficients except those between 2π/36 and 2π/84 are zero.
In the code that I have posted is figure(4)
EDIT:
auxTWO=fliplr(niniofourier(1:330));
for i=1:330
niniofourierb(i+330)=auxTWO(i);
end
niniosi=ifft(niniofourierb);
niniosib=niniosi(1:330);
If I add this code to make the mirroring of the first half, I still get an awful figure

Last edited:
It sounds like you are removing the coefficients of the very periodicity that you expect it to have. Shouldn't those be the ones you keep? If you remove the period, you should expect noise. Is that what you expected? Is that what you got?

PS. Before you go too far, I think you should apply some time series analysis like Box-Jenkins and see what autocorrelations are in the data.

## 1. What is Fourier transformation?

Fourier transformation is a mathematical technique used to decompose a complex signal into its individual frequency components. It converts a signal from the time or spatial domain to the frequency domain, allowing us to analyze the different frequencies present in the signal.

## 2. How is Fourier transformation performed in Matlab?

In Matlab, Fourier transformation can be performed using the fft function. This function takes in a signal as input and returns its discrete Fourier transform (DFT) as an array of complex numbers. The inverse Fourier transformation can be performed using the ifft function.

## 3. What is the difference between Fourier transformation and Fourier series?

Fourier transformation is used for continuous signals, while Fourier series is used for discrete signals. Fourier transformation converts a signal from the time domain to the frequency domain, while Fourier series decomposes a signal into a sum of sinusoidal functions.

## 4. Can Fourier transformation be applied to any type of signal?

Yes, Fourier transformation can be applied to any signal, regardless of its type (e.g. audio, image, video). However, the signal must be converted to a digital format before applying Fourier transformation.

## 5. What are the applications of Fourier transformation?

Fourier transformation has various applications in fields such as signal processing, telecommunications, image processing, and data analysis. It is commonly used for filtering, noise reduction, pattern recognition, and spectral analysis of signals.

• MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
• MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
4K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
7K