how do i calculate the partial sum of a fourier series?
3 views (last 30 days)
Show older comments
I have the following function:
f(x)=1/2*(cos(x)+|cos(x)|), x ∈ [-π,π]
how do I calculate the partial sum using matlab code?
0 Comments
Answers (1)
Jyotsna Talluri
on 18 May 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
0 Comments
See Also
Categories
Find more on Fourier Analysis and Filtering 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!