View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Fourier series coefficients

5.0 | 3 ratings Rate this file 14 Downloads (last 30 days) File Size: 5.35 KB File ID: #41980 Version: 1.1
image thumbnail

Fourier series coefficients



28 May 2013 (Updated )

Calculate the Fourier series coefficients and amplitude and phase spectra.

| Watch this File

File Information

Calculate the Fourier coefficients of the series expansion of a function, and the amplitude and phase spectra. The script contains some theory and 3 different methods to calculate the coefficients.


- FUN: character string representing the function with "t" as the independent variable (e.g. '10*cos(2*pi*3*t-pi/4)'). Dot-arithmetic operators must be used (.* ./ .\ .^). FUN must be defined for [T0,T0+T]
- T0: initial "t" for the definition of FUN
- T: period of the function
- M: number of frequencies (default: 5)
- N: number of data points per period (default: 100)
- METHOD: 1 (least-squares), 2 (integrals [default]) or 3 (FFT)
- RES: 1 (plot results) or 0 (do not plot [default])
- NUM_P: number of periods the function will be sampled at (default: 1)

- FREQ: frequencies
- COEFF: Fourier series coefficients in the form in the form [a0 a1 ... aM b1 ... bM], where f(t) = a0 + \sum_{m=1}^M { a_m cos(2pi m t/T) + b_m sin(2pi m t/T) }
  So the corresponding frequencies are: 0, 1/T, 2/T, ..., M/T
- APSPEC: the first column contains the amplitude spectrum, and the second column the phase spectrum
- If RES=1:
  Figure the original function and the Fourier series expansion, and another with the amplitude and phase spectra

Required Products MATLAB
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
11 Jan 2014 karlosgk

karlosgk (view profile)

Very nice, thanks a lot. Do you know a way to do all this if the function is raw data?

11 Jan 2014 karlosgk

karlosgk (view profile)

08 Dec 2013 Fan D.Chen

Fourier series coefficients

03 Jun 2013 1.1

Changed input and added screensht

Contact us