You are on page 1of 6

Señales variables con Fourier en matlab

Tren de pulsos

%onda cuadrada 50% duty


clc;
clf;
figure(1);
subplot(3,1,1);
tmax=20;
t = 0:0.01:tmax;
y1 = square(2*pi*.25*t,50);
for i=1:1:length(y1)
if y1(i)<0
y1(i)=0;
end
end
plot(t,y1,'r','LineWidth',1.5)
grid on;
axis([0 tmax -1.5 1.5]);

%pwm
pau=0.5;
for n=0:5:100
t = 0:0.01:tmax;
y = square(2*pi*.25*t,n);
for i=1:1:length(y)
if y(i)<0
y(i)=0;
end
end
subplot(3,1,2);
plot(t,y,'r','LineWidth',1.5)
title(['Duty: ',num2str(n),'%']);
grid on;
axis([0 tmax -1.5 1.5]);
subplot(3,1,3);
ff=fft(y);
plot(t,ff,'k','LineWidth',1.5);
grid on;
axis([0 1 -100 500]);
pause(pau);
end
Onda triangular

%reconstruccion triangular
clc;
clf;
figure(2);
n=0;
%plot3([1 1 1],[2 4 1],[1 1 1])
%x(t)=(8/pi^2)sum(((-1)^((k-1)/2)))/k^2) sen(2*pi*Fo*k*t),n=1,inf)
f=2;
yt=0;
col=['r' 'b' 'k' 'g' 'c' 'y'];
for k=1:1:6
t=0:0.001:2;
z=length(t);

for i=1:1:z
z1(i)=n;
end
n=n+1;
y=sin(2*pi*f*k*t);
y1=((-1)^((k-1)/2))/k^2;
yf=y1*y;
yt=yt+(8/pi^2)*y1*y;
subplot(1,2,1);
plot3(z1,t,yf,col(k),'LineWidth',1.5);
hold on;
axis([0 6 0 .5 -1 1]);
grid on;
subplot(1,2,2);
plot(t,yt,'r','LineWidth',1.5);
axis([0 1 -1 1]);
pause(.5);
end
Diente de sierra

%reconstruccion diente sierra


clc;
clf;
figure(3);
n=0;
%plot3([1 1 1],[2 4 1],[1 1 1])
%x(t)=(8/pi^2)sum(((-1)^((k-1)/2)))/k^2) sen(2*pi*Fo*k*t),n=1,inf)
f=2;
yt=0;
col=['r' 'b' 'k' 'g' 'c' 'y'];
for k=1:1:6
t=0:0.001:2;
z=length(t);
for i=1:1:z
z1(i)=n;
end
n=n+1;
y=sin(2*pi*f*k*t);
y1=1/k;
yf=y1*y;
yt=yt+(-2/pi)*y1*y;
subplot(1,2,1);
plot3(z1,t,yf,col(k),'LineWidth',1.5);
hold on;
axis([0 6 0 .5 -1 1]);
grid on;
subplot(1,2,2);
plot(t,yt,'r','LineWidth',1.5);
axis([0 1 -1 1]);
pause(.5);
end

You might also like