Utilizamos el siguiente codigo en MATLAB para hallar los coeficientes de fourier de la función:
coeficientes= 0;
clc
format long
syms t
syms k
m=t;
mt=0;
f=int((x*exp(-j*pi*k*t)),-1,1)/2;
x=0;
for C=-x:1:x
if C==0
V=0
else
xi=f*exp(j*pi*k*t);
V=subs(xi,k,C);
end
mt=mt+V;
end
for ti=-2:0.01:2
xti=subs(mt,t,ti);
plot(ti,xti,'m')
grid on
hold on
title('Fourier')
ylabel('x(t) ')
xlabel('Tiempo')
end
coeficientes=1;
clc
format long
syms t
syms k
m=t;
mt=0;
f=int((x*exp(-j*pi*k*t)),-1,1)/2;
x=1;
for C=-x:1:x
if C==0
V=0
else
xi=f*exp(j*pi*k*t);
V=subs(xi,k,C);
end
mt=mt+V;
end
for ti=-2:0.01:2
xti=subs(mt,t,ti);
plot(ti,xti,'--m')
grid on
hold on
title('Fourier')
ylabel('x(t) ')
xlabel('Tiempo')
end
coeficientes=5;
clc
format long
syms t
syms k
m=t;
mt=0;
f=int((x*exp(-j*pi*k*t)),-1,1)/2;
x=50;
for C=-x:1:x
if C==0
V=0
else
xi=f*exp(j*pi*k*t);
V=subs(xi,k,C);
end
mt=mt+V;
end
for ti=-2:0.01:2
xti=subs(mt,t,ti);
plot(ti,xti,'--m')
grid on
hold on
title('Fourier')
ylabel('x(t) ')
xlabel('Tiempo')
end
Analizando, entre mas coeficientes se utilicen la gráfica va ser mas exacta a la original pero esto implica muchos costos ademas paciencia porque el computador se demora mucho mas en procesar; como el pc que yo tengo es un mini no puedo utilizar mas coeficientes ya que MATLAB utiliza muchos recursos y pues no corre bien con tantos coeficientes.















