How to Use Matlab's FFT Function for Discrete Fourier Transform?

In summary: F(\omega)## is the Fourier transform of ##f(t)##.Therefore, to compute the first-order derivatives at the grid points, you can use the FFT to obtain the Fourier coefficients of ##f(x)##, then multiply each coefficient by ##i \omega## (where ##\omega## is the corresponding frequency for that coefficient) and take the inverse FFT to get the derivatives at the grid points. You can then compare these derivatives with the actual derivative of ##f(x)## to assess the accuracy of the FFT method.
  • #1
wu_weidong
32
0
Hi,
I am very new to Matlab, and I'm supposed to use the built-in FFT function to do discrete Fourier Transform for f(x) = sin x + 4 cos(5x) + (sin(6x))^2 on the interval [-pi, pi] with a uniform partition for the interval with n = 9. Then I have to
(a) Plot the magnitudes of the Fourier coefficients and
(b) Compute the first-order derivates at the grid points via FFT and compare them with f'(x).

Here's what I have for part (a):

x = -pi:0.25*pi:pi;
y = sin(x)+4*cos(5*x) + sin(6*x).*sin(6*x);
V=fft(y,9);
plot(abs(V));

I'm a little confused with what the function fft returns. Does it return the Fourier coefficients of f(x) in my program?

I got
V =
-0.0000
-5.9965 + 2.1842i
-4.5019 - 4.8898i
-8.3033 -15.3964i
0.8017 + 2.1116i
0.8017 - 2.1116i
-8.3033 +15.3964i
-4.5019 + 4.8898i
-5.9965 - 2.1842i

I also don't know how to find the first-order derivates at the grid points via FFT for part (b). What function do I use?

Thank you very much!

Regards,
Rayne
 
Physics news on Phys.org
  • #2
wu_weidong said:
Does it return the Fourier coefficients of f(x) in my program?
I returns the coefficient of the frequency components. However, note that the FFT assumes that the signal starts at 0. Here, it will be necessary to adjust the complex phase because the actual signal starts at ##-\pi##.
http://fourier.eng.hmc.edu/e101/lectures/handout3/node2.html
Note also that the order of the elements is that the positive frequencies components appears first, in increasing order of frequency, and then the negative frequencies components, again in increasing order of frequency (i.e., from highest absolute value of frequency up to 0).

wu_weidong said:
I also don't know how to find the first-order derivates at the grid points via FFT for part (b). What function do I use?
The relevant transform pair is
$$
\left( \frac{d}{dt} \right)^n f(t) \Leftrightarrow (i \omega)^n F(\omega)
$$
 

1. What is Matlab?

Matlab is a programming language and software environment commonly used in scientific and engineering applications. It is known for its powerful data analysis and visualization capabilities, as well as its extensive library of functions for various mathematical operations.

2. What is Fast Fourier Transform (FFT)?

FFT is an algorithm used for quickly computing the discrete Fourier transform of a sequence of data points. It is commonly used for analyzing signals and data in the frequency domain, such as in audio and image processing applications.

3. How do you use FFT in Matlab?

To use FFT in Matlab, you can use the built-in function fft(), which takes in a vector of data points as input and returns the discrete Fourier transform. You can also use the fft2() function for 2D data or fftn() for n-dimensional data.

4. What are some applications of FFT in Matlab?

FFT in Matlab is commonly used for analyzing and processing signals and data in various fields such as audio and image processing, telecommunications, and biomedical engineering. It can also be used for analyzing financial data, weather patterns, and other types of time series data.

5. Are there any limitations to using FFT in Matlab?

While FFT in Matlab is a powerful tool, it does have some limitations. For very large data sets, the computation time and memory usage may be significant. Additionally, FFT assumes that the data is periodic and may not work well with non-periodic or non-stationary data. It is important to understand the limitations and assumptions of FFT when using it in Matlab.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • Calculus and Beyond Homework Help
Replies
3
Views
283
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
5K
Back
Top