Professional Documents
Culture Documents
X1 = sin(pi/4*n1)+2*cos(pi/5*n1); %funciones
X2 = 2.^(n2).*sin(3*pi/4*n2);
X3 = rand(1,21);
X4 = [zeros(1,3),2*ones(1,1),zeros(1,1),ones(1,11)];
X5 = 3*sin(2/5*n5);
subplot (5,1,1);
stem(n1,X1),xlabel('n'),ylabel('y[n]'),title('función sinusoidal
periodica')%gráficas
grid;
subplot(5,1,2);
stem(n2,X2),xlabel('n'),ylabel('y[n]'),title('función senoidal
creciente')
grid;
subplot(5,1,3);
stem(n3,X3),xlabel('n'),ylabel('y[n]'),title('función aleatoria')
grid;
subplot(5,1,4);
stem(n4,X4),xlabel('n'),ylabel('y[n]'),title('impulso y escalón')
grid;
subplot(5,1,5);
stem(n5,X5),xlabel('n'),ylabel('y[n]'),title('función senoidal no
periodica')
grid;
1
%Autocorrelación
N=1000;
n=0:N-1;
x=sin(2*pi*n/100);
figure,subplot(4,1,1);
plot(n,x);
title('sine wave');
xlabel('Time, [samples]');
ylabel('Amplitude');
grid;
Rxx=xcorr(x);%autocorrelacion
N1=-N+1:N-1;
subplot(4,1,2);
plot(N1,Rxx);
grid;
title('Autocorrelation function of the sine wave');
2
N2=-tam+1:tam+1;
Fxx=xcorr(X3);
subplot(4,1,4);
stem(N2,Fxx);
grid;
title('autocorrelation of random function');
%Complex function
n=0:20;
f=2.*exp(-1j.*pi/7.*(n+1));
figure,subplot(4,1,1);
stem(n,real(f));
xlabel('Time, [samples]');
ylabel('Amplitude');
title('real part of exponential wave');
grid;
subplot(4,1,2);
stem(n,imag(f));
title('imaginary part of exponential wave');
grid;
subplot (4,1,3);
angle=angle(f);
stem(n,abs(f));
title('magnitude of exponential wave');
3
grid;
subplot(4,1,4);
stem(n,unwrap(angle));
title('angle of exponential wave');
grid;
%ANS: the only periodical signal in numeral 4 is the first one, the
others
%are not. its period is 40. one discrete-time signal is periodic if
x[n]=x[n+kT] where T is the period a k is a constant.Also, its
%autocorrelation must be periodic too.
4
%equal to its period. this maximum value is also the energy of the
signal,
%the sum of the numbers squares.