You are on page 1of 4

function y = periodica(x)

tn = ceil( (x + pi) / (2*pi) );


y = ( (x - tn*2*pi) + 2*pi ) / pi;

Llámala desde el código principal, y grafica

x = -2*pi : .01 : 2*pi;


y = periodica(x);
plot(x, y)

>> n-0:15;

Undefined function or variable 'n'.

>> fo=400

fo =

400

>> fo=400;

>> n-0:15;

Undefined function or variable 'n'.

>>

>> n-0:15;

Undefined function or variable 'n'.

>> n=0:15;

>> Xn=exp(j*n/3);

>> Xk=fft(Xn)

Xk =
Columns 1 through 2

-2.2083 + 1.6496i 13.9054 - 6.6357i

Columns 3 through 4

1.9775 - 0.5026i 1.1139 - 0.0586i

Columns 5 through 6

0.7803 + 0.1130i 0.5923 + 0.2096i

Columns 7 through 8

0.4637 + 0.2758i 0.3636 + 0.3272i

Columns 9 through 10

0.2775 + 0.3715i 0.1970 + 0.4129i

Columns 11 through 12

0.1156 + 0.4547i 0.0263 + 0.5006i

Columns 13 through 14

-0.0804 + 0.5555i -0.2225 + 0.6286i

Columns 15 through 16
-0.4405 + 0.7407i -0.8615 + 0.9571i

>> k=n;

>> subplot(221)

>> stem(k,real(Xk));

>> title('parte imaginaria de x(K)');

>> subplot(223)

>> stem (k,imag(Xk));

>> title('parte imaginaria de x(K)');

>> % RECUPERAR LA SEÑAL X(N)

>> Xn=ifft(Xk);

>> subplot(222)

>> stem (n,real(Xn));

>> title('parte real de Xn');

>> subplot(224)

>> stem(n,imag(Xn));

>> title('parte imaginaria de Xcn');

>>

CONBOLUCION

clc
clear
pause on
x=[0 1 2 3 4 3 2 1 0]; %Respuesta al impulso unitario
h=[1 1 1 1 1 1 1 1 ]; %Señal de entrada
m=length(x);
n=length(h);
%invierte el vector h
hi=fliplr(h);
k=20;
X=[x,zeros(1,40-m)];
X= X([ end-k+1:end 1:end-k ]);
H=[h,zeros(1,40-n)];
H= H([ end-k+1:end 1:end-k ]);
xn=-20:20-1;
Y=zeros(1,40);
p=zeros(1,40);
h1=subplot(3,1,1);
plot(xn,X,'-g')
ylabel('h(t)')
title('Respuesta al impulso unitario')
% colocar(h1,'YLim',[a b])
h2=subplot(3,1,2);
plot(xn,H,'-y')
% colocar(h2,'YLim',[a b])
pause(3)
h2=subplot(3,1,3);
plot(xn,Y,'-m')
%ciclo
Hi=[hi,zeros(1,40-n)];
for i=1:40-n
p=X.*Hi;
Y(i+n-1)=sum(p);
subplot(3,1,2);
plot(xn,Hi,'-r')
ylabel('x(t)')
title('Señal de entrada')
subplot(3,1,3)
plot(xn,Y,'-m')
xlabel('Tiempo [s]')
ylabel('y(t)')
title('Señal de salida')
Hi= Hi([ end 1:end-1 ]);
pause(0.5)
end
pause off
salida=Y(abs(Y)>0);
salida2=conv(x,h);
[salida',salida2']

You might also like