fourier series of this function
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i want the fourier seris of function:
my code:
clear all
clc
syms x
f=(x+2).*(x>-2)-(x+2).*(x>-1)+(1).*(x<=1)-(1).*(x<=-1)+(2-x).*(x>1)-(2-x).*(x>=2);
N=10;
a_0=(1/pi)*int(f*cos(0*x),-pi,pi)
for n=1:N
a_n(n)=(1/pi)*int(f*cos(n*x),-pi,pi);
b_n(n)=(1/pi)*int(f*sin(n*x),-pi,pi);
end
a_n
b_n
f_new=a_0/2;
for n=1:N
f_new=f_new+a_n(n)*cos(n*x)+b_n(n)*sin(n*x);
end
subs(f_new,x,5)
subs(f,x,5)
the error:
Error using symengine
Invalid integrand.
Error in sym/int (line 162)
rSym = mupadmex('symobj::intdef',f.s,x.s,a.s,b.s,options);
Error in Untitled3 (line 7)
a_0=(1/pi)*int(f*cos(0*x),-pi,pi)
my function:
2 commentaires
infinity
le 27 Juin 2019
Hello,
It is seen that the function "f" is not easy for Matlab to find it intergrand by using the fucntion "int". Maybe, you should try to split the piecewise function "f" into some small intervals, for example, [0, -2], [-2, -1], [-1, 1], .... Then, you can get the integral over these intervals.
Réponses (0)
Voir également
Catégories
En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!