Está en la página 1de 6

Ejercicio 1

%Series_de_Fourier.m
%ALAN FREDDY OLMOS LAURA
%------------------
clear all
clc
%Representación de la señal x(t)
T=2; %Periodo
w=2*pi/T; %Frecuencia angular
C=2; %Ciclos por lado mas uno en el origen
t=-C*T+T/2:0.001:C*T-T/2; %Vector tiempo
hold on
grid on
grid minor
x=(t+3).*heaviside(t+3)-
2.*(t+2).*heaviside(t+2)+2*(t+1).*heaviside(t+1)-
2*(t).*heaviside(t)+2*(t-1).*heaviside(t-1)-2*(t-
2).*heaviside(t-2);
plot(t,x,'g','LineWidth',2)
%Seriede Fourier con n armonicos
k=50; %Numero de armonicos serie
s=0;
for n=1:k
an=(2/((n*pi)^2))*(1-(-1)^n);
bn=0;
p=an.*cos(n*w*t)+bn.*sin(n*w*t);
s=s+p;
end
a0=1;
f=a0/2+s;
plot(t,f)
xlabel('t');
ylabel('f(t)');
title('Señal y Serie de Fourier ALAN FREDDY OLMOS
LAURA');
legend('Señal','Serie de Fourier')
Ejercicio 2
%Series_de_Fourier.m
%ALAN FREDDY OLMOS LAURA
%------------------
clear all
clc
%Representación de la señal x(t)
T=2*pi; %Periodo
w=2*pi/T; %Frecuencia angular
C=2; %Ciclos por lado mas uno en el origen
t=-C*T+T/2:0.001:C*T-T/2; %Vector tiempo
hold on
grid on
grid minor
x=0;
for n=-C:C
xt=((t>=(n*T-T/2))-(t>=(n*T+T/2))).*(t-n*T)
x=xt+x;
end
plot(t,x,'g','LineWidth',2)
%Series de Fourier con n armonicos
k=50; %Numero de armonicos serie
s=0;
for n=1:k
an=0;
bn=(2/(n))*((-1)^(1+n));
p=an.*cos(n*w*t)+bn.*sin(n*w*t);
s=s+p;
end
a0=0;
f=a0/2+s;
plot(t,f)
xlabel('t');
ylabel('f(t)');
title('Señal y Serie de Fourier ALAN FREDDY OLMOS
LAURA');
legend('Señal','Serie de Fourier')

Ejercicio 3
%Series_de_Fourier.m
%ALAN FREDDY OLMOS LAURA
%------------------
clear all
clc
%Representación de la señal x(t)
T=pi/2; %Periodo
w=2*pi/T; %Frecuencia angular
C=2; %Ciclos por lado mas uno en el origen
t=-C*T+T/2:0.001:C*T-T/2; %Vector tiempo
hold on
grid on
grid minor
x=0;
for n=-C:C
xt=0.*((t>=(n*T-T/2))-(t>=(n*T)))
+cos(2.*(t+n*T)).*((t>=(n*T))-(t>=(n.*T+T/2)));
x=xt+x;
end
plot(t,x,'g','LineWidth',2)
%Serie de Fourier con n armonicos
k=50;
s=0;
for n=1:k
an=(2*(-1)^n)/(pi*(1-4*n^2));
bn=(4*n*(-1))/(pi*(1-4*n^2));
p=an.*cos(n*w*t)+bn.*sin(n*w*t);
s=s+p;
end
a0=2/pi;
f=a0/2+s;
plot(t,f)
xlabel('t');
ylabel('f(t)');
title('Señal y Serie de Fourier ALAN FREDDY OLMOS
LAURA');
legend('Señal','Serie de Fourier')
Ejercicio 4
%Series_de_Fourier.m
%ALAN FREDDY OLMOS LAURA
%------------------
clear all
clc
%Representación de la señal x(t)
T=2*pi; %Periodo
w=2*pi/T; %Frecuencia angular
C=2; %Ciclos por lado mas uno en el origen
t=-C*T+T/2:0.001:C*T-T/2; %Vector tiempo
hold on
grid on
grid minor
x=0;
for n=-C:C
xt=sin((t+n*T)).*((t>=(n*T))-(t>=(n.*T+T/2)));
x=xt+x;
end
plot(t,x,'g','LineWidth',2)
%Series de Fourier con n armonicos
k=50; %Numero de armonicos Serie
s=0;
for n=2:k
an=(1/pi).*(((-1).^n+1)/(1-n.^2));
bn=0;
p=an.*cos(n*w*t)+bn.*sin(n*w*t);
s=s+p;
end
a0=2/pi;
f=a0/2+s+(sin(t)/2);
plot(t,f)
xlabel('t');
ylabel('f(t)');
title('Señal y Serie de Fourier ALAN FREDDY OLMOS
LAURA');
legend('Señal','Serie de Fourier')

También podría gustarte