how do i calculate the partial sum of a fourier series?

7 visualizaciones (últimos 30 días)
Hala Smadi
Hala Smadi el 15 de Mayo de 2020
Respondida: Jyotsna Talluri el 18 de Mayo de 2020
I have the following function:
f(x)=1/2*(cos(x)+|cos(x)|), x ∈ [-π,π]
how do I calculate the partial sum using matlab code?

Respuestas (1)

Jyotsna Talluri
Jyotsna Talluri el 18 de Mayo de 2020
There is not direct built-in function yet to do that .You can do that by your own code.Try the script below with your function
syms k ;
evalin(symengine,'assume(k,Type::Integer)');
syms x L n;
a = @(f,x,k,L) int(f*cos(k*sym('pi')*x/L)/L,x,-L,L);
b = @(f,x,k,L) int(f*sin(k*sym('pi')*x/L)/L,x,-L,L);
fs = @(f,x,n,L) a(f,x,0,L)/2 + ...
symsum(a(f,x,k,L)*cos(k*pi*x/L) + b(f,x,k,L)*sin(k*pi*x/L),k,1,n);
simplifiedfs = @(f,x,n,L) pretty(simplify(fs(f,x,n,L)));
Here f denotes your function ,f= cos(x)+abs(cos(x)); L denotes limits L = pi and x is the variable by which the function is varying.
fs(f,x,n,pi) calculates the partial sum of Fourier series of function f from K =1 to n

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by