You are on page 1of 5

%%Plot the following signals.

%César Sierra Pardo


clear
clc
n1= 0:20; %vectores de tamaño
n2= 0:10;
n3= 0:20;
n4= -5:10;
n5= 0:30;

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');

subplot(4,1,3); %grafica de la funcion del inciso anterior


stem(n3,X3);
grid;
title('random function');

tam=20; %tamaño de la función a autocorrelacionar

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;

%Answer the following questions and upload the .m file to SAVIO


%¿Which of the signals in numeral 4 are periodic? calculate their
period.
%what is the requirement for a discrete-time signal to be periodic?

%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.

%What is the length of the autocorrelation function of a signal with N


samples? What is the maximum value of the autocorrelation?

%ANS: the lenght of the autocorrelation function of a signal with N


samples
%is 2N. Its maximum value occurs when the displacement is equal to
cero or

4
%equal to its period. this maximum value is also the energy of the
signal,
%the sum of the numbers squares.

%describe graphs in numeral 6. are they odd or even?

%ANS: La grafica de la parte real de la función exponencial tiene una


forma
%periódica, cosenoidal. una amplitud de 2 y un periodo de 14. Es casi
una
%función par, pues está adelantada una unidad

%La gráfica de la parte imaginaria de la función exponencial tiene una


%forma periódica, senoidal. Una amplitud de 2 y un periodo de 14. es
casi
%una función impar, pues está adelantada una unidad.

%La gráfica de la magnitud de la señal exponencial tiene un valor


contante,
%por lo que es par.

%La gráfica de la fasede la señal exponencial tiene forma de linea


recta
%con pendiente negativa, su valor decrece a un ritmo constante. Es
impar.

Published with MATLAB® R2018a

You might also like