Está en la página 1de 1

function [F, S]=fourier(t, x)

N=length(t);
dt=abs(t(2)-t(1));
k=0:N-1;
x=fftshift(x);
for i=1:N
S(i)=sum(x.*exp(-%i*2*%pi*(i-1).*(k)/N));
end
S=fftshift(S);
fo=1/(N*dt);
F=(-N/2:N/2-1)*fo;
endfunction

A=1;
T=1;
a0=A/2;
y=a0;
paso=0.0001;
t=0:paso:5*T;

n=5;

for i=1:n
y=y+2*A/(%pi^2*(i)^2)*((-1)^i-1)*cos(2*%pi*i*t/T);
end
figure(1)
xtitle("Serie de Fourier Señal Triangular")
xlabel("Tiempo")
xlabel("Amplitud")
plot(t,y,"b")

También podría gustarte