Fourier Series and Harmonics

f(x) = 2 between -2<x<0 and f(x) = 2-x between 0<x<2
f(x) = f(x+4)
Q) a) Find the coefficients of the first 5 harmonics. b) Plot the function and its approximating 5 term fourier series c) Sketch the fourier series (not the 5 term approximation) over the interval -6=<x=<6.
Can anyone help me with the above question or point me to an example of a similar fourier series question?
I do have the fnc M-file. I have entered the following:
------------------------------------------
function result=fnc(x)
result=(x+4)
-------------------------------------------------
I also believe that my L value is 2 and the n value is 5. I then need to enter fourier('fnc',L,n,'yes')
Is this correct?

Answers (1)

I’m not exactly sure what you need to do, but this should get you started:
syms x w
f1a = symfun(2, x); % Function Of ‘x’
f1b = symfun(2 - x, x); % Function Of ‘x’
Ff1a = int(f1a*exp(1i*w*n*x), x, -2, 0); % Fourier Series
Ff1b = int(f1b*exp(1i*w*n*x), x, 0, 2); % Fourier Series
Ff1 = simplify(Ff1a+Ff1b); % Combine For Complete Transform
You need to evaluate the functions and take their transforms piecewise, then sum them to get the complete transform. I defined ‘f1a’ and ‘f1b’ as functions here to make it easier for you to evaluate them at (x+4). You will have to use the subs function to evaluate them at their various harmonics (integer values of ‘n’).

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Asked:

on 6 Nov 2014

Answered:

on 6 Nov 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!