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

Click For Summary
SUMMARY

This discussion focuses on using Matlab's FFT function to perform a discrete Fourier Transform (DFT) on the function f(x) = sin(x) + 4 cos(5x) + (sin(6x))^2 over the interval [-π, π] with a uniform partition of n = 9. The user, Rayne, successfully computes the Fourier coefficients using the FFT function but seeks clarification on the output and how to compute first-order derivatives at grid points. The FFT returns frequency component coefficients, and adjustments are necessary due to the signal starting at -π. The relevant transform pair for derivatives is provided as (d/dt)^n f(t) ↔ (iω)^n F(ω).

PREREQUISITES
  • Understanding of Matlab programming and syntax.
  • Familiarity with the Fast Fourier Transform (FFT) algorithm.
  • Knowledge of discrete Fourier Transform concepts.
  • Basic calculus, specifically differentiation of functions.
NEXT STEPS
  • Explore Matlab's FFT documentation for detailed function usage and parameters.
  • Learn about phase adjustments in FFT for non-zero starting points.
  • Study the mathematical basis of Fourier transforms and their applications in signal processing.
  • Investigate how to compute derivatives in the frequency domain using FFT.
USEFUL FOR

Matlab users, signal processing engineers, and anyone interested in applying Fourier analysis to functions for analysis and visualization.

wu_weidong
Messages
27
Reaction score
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
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)
$$
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
12
Views
6K