how do i calculate the partial sum of a fourier series?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Jyotsna Talluri
2020-5-18
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!