How to find Fourier series for the periodic function?

9 views (last 30 days)
Hello, I need to find the the Fourier series for the periodic function f(t) = 0 for -pi < t <= 0, and f(t) = t for 0 < t <= pi, and f(t) = f(t + 2pi). I can do the calculation by hand, but I want to ask if Matlab can help me solve this problem. If yes, could you provide me some instruction of how to write codes into Matlab to get the series that I want? Thank you so much!
p/s: This question has nothing to do with my homework, I just simply want to know if Matlab can help me solve this kind of problem so that I can save a lot of time and increase the accurateness of my answer if I encounter this type of problem in the future.
  4 Comments
Torsten
Torsten on 11 Jan 2023
You don't need to write down the coefficients. You need to write down the formula by which the coefficients are computed.
Don't you have a textbook which states
a_i = 1/pi * integral_{t=-pi}^{t=pi} f(t) * cos(i*t) dt
b_i = 1/pi * integral_{t=-pi}^{t=pi} f(t) * sin(i*t) dt
?
You can compute the values for these integrals using MATLAB's "int".
Or you go the "lazy way" Matt J suggested in his answer. I did not yet know of this MATLAB function.

Sign in to comment.

Accepted Answer

Matt J
Matt J on 11 Jan 2023
Edited: Matt J on 11 Jan 2023
You can use fourier, e.g.
syms x n T
f=rectangularPulse(x);
series = simplify( fourier(f,2*pi*n/T)/T )
series = 
  5 Comments
Matt J
Matt J on 11 Jan 2023
I think rather than series(0)=1 it should be 1/T.
syms x n T
f=rectangularPulse(x);
series(n) = simplify( fourier(f,2*pi*n/T)/T );
a0=limit(series(n),n,0)
a0 = 

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!