Series de fourier

Páginas: 3 (627 palabras) Publicado: 29 de noviembre de 2011
EE 321

Electrical Circuits II Generating Fourier Series with Matlab

Fall 2004

Generating Fourier series with Mathematica is extremely simple provided, of course, that you are familiar withMathematica. For example, for an even, unit amplitude, square wave with unit period, the Fourier series is given by f (t) = 4 π (−1)n+1 cos((2n − 1)2πt) n=1 2n − 1


(1)

A Mathematica command todefine this function is
f[t_, nTerms_] := 4/Pi Sum[(-1)ˆ(n+1)Cos[(2 n - 1)2 Pi t]/(2 n - 1), {n, 1, nTerms}]

This command defines a function f with two arguments. The first, t, is the time and thesecond, nTerms, is the number of terms to be used when evaluating the series. After issuing this command one can plot the function f with, for example, a command such as
Plot[f[t, 20], {t, 0, 2}]This says to plot the function using the first twenty harmonics with time ranging from zero to two. Alternatively, one can evaluate the function at a point. For example, the statement f[0.123,15] wouldevaluate the series at the point 0.123 using the first 15 non-zero harmonics. However, how would one plot the series in Matlab? Unfortunately you have to work a bit harder (at least given my limitedknowledge of Matlab) but it is straightforward and generating such plots is a good way to check that you have the series correct. Here is a transcript, with comments, of a session which generates a plotof the series shown above. The first 20 non-zero harmonics are used.

% Set the number of harmonics in the series. nTerms=20; % n = a vector of integers of all the harmonic numbers
File:matlab-fourier-series.tex

1

n=1:nTerms; % an = coefficients of harmonics an=4*(-1).ˆ(n+1)./(pi*(2*n-1)); % t = time at which function is sampled t=linspace(0,2,401); % f = ultimately will contain theFourier series of the % desired function. Initialize to zero. Length % is the same as the number of time samples. f = zeros(1,length(t)); % Use a loop to add each harmonic to the series. for n=1:nTerms...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • series de fourier
  • series de fourier
  • series fourier
  • Serie De Fourier
  • Series de Fourier
  • Series de fourier
  • Series de fourier
  • Series De Fourier

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS