0% found this document useful (0 votes)
163 views

LABEX1 - Resuelta

This document contains a laboratory report from a Digital Signal Processing course. It includes MATLAB programs and questions related to generating and analyzing various types of discrete-time signals in the time domain, including unit sample sequences, exponential sequences, sinusoidal sequences, and random sequences. The student provides the MATLAB code used to generate the signals and answers questions about how the different parameters control aspects of the signals like amplitude, frequency, growth/decay rates, etc.

Uploaded by

Antonio Ledezma
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
163 views

LABEX1 - Resuelta

This document contains a laboratory report from a Digital Signal Processing course. It includes MATLAB programs and questions related to generating and analyzing various types of discrete-time signals in the time domain, including unit sample sequences, exponential sequences, sinusoidal sequences, and random sequences. The student provides the MATLAB code used to generate the signals and answers questions about how the different parameters control aspects of the signals like amplitude, frequency, growth/decay rates, etc.

Uploaded by

Antonio Ledezma
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 21

UNIVERSIDAD PRIVADA BOLIVIANA

LABORATORIO I
Procesamiento Digital de seales

Nombre: Antonio R. Ledezma Arandia Docente: ing. Zurita Villarroel Grover Fecha: 23-08-2013

Name:

Antonio R. Ledezma Arandia

Laboratory Exercise 1
DISCRETE-TIME SIGNALS: TIME-DOMAIN REPRESENTATION
1.1 GENERATION OF SEQUENCES Unit sample and unit step sequences

Project 1.1

A copy of Program P1_1 is given below. % Program P1_1 % Generation of a Unit Sample Sequence clf; % Generate a vector from -10 to 20 n = -10:20; % Generate the unit sample sequence u = [zeros(1,10) 1 zeros(1,20)]; % Plot the unit sample sequence stem(n,u); xlabel('Time index n');ylabel('Amplitude'); title('Unit Sample Sequence'); axis([-10 20 0 1.2]); Answers: Q1.1 The unit sample sequence

u[n] generated by running Program P1_1 is shown below:

Q1.2

The purpose of The purpose of

clf command is Limpia la ventana de la figura axis command is Asigna los margenes de x, y en la grafica Coloca titulo General a nuestra grafica Coloca un titulo a nuestro eje x - Coloca un titulo a nuestro eje y

The purpose oftitle command is

The purpose ofxlabel command is The purpose ofylabelcommand is

Q1.3

The modified Program P1_1 to generate a delayed unit sample sequence ud[n] with a delay of 11 samples is given below along with the sequence generated by running this program . % Program P1_1 % Generation of a Unit Sample Sequence clf; % Generate a vector from -10 to 20 n = -10:20; % Generate the unit sample sequence u = [zeros(1,10) zeros(1,11) 1 zeros(1,20-11)]; % Plot the unit sample sequence stem(n,u); xlabel('Time index n');ylabel('Amplitude'); title('Unit Sample Sequence'); axis([-10 20 0 1.2]);

Q1.4

The modified Program P1_1 to generate a unit step sequence sequence generated by running this program . % Program P1_1 % Generation of a Unit Sample Sequence clf; % Generate a vector from -10 to 20 n = -10:20; % Generate the unit sample sequence u = [zeros(1,10) zeros(1,11) 1 ones(1,20-11)]; % Plot the unit sample sequence stem(n,u); xlabel('Time index n');ylabel('Amplitude'); title('Unit Sample Sequence'); axis([-10 20 0 1.2]);

s[n] is given below along with the

Q1.5

The modified Program P1_1 to generate a unit step sequence sd[n] with an advance of 7 samples is given below along with the sequence generated by running this program .

% Program P1_1 % Generation of a Unit Sample Sequence clf; % Generate a vector from -10 to 20 n = -10:20; % Generate the unit sample sequence u = [zeros(1,10-7) 1 ones(1,20+7)]; % Plot the unit sample sequence stem(n,u); xlabel('Time index n');ylabel('Amplitude'); title('Unit Sample Sequence'); axis([-10 20 0 1.2]);

Project 1.2

Exponential signals

A copy of Programs P1_2 and P1_3 are given below . % Program P1_2 % Generation of a complex exponential sequence clf; c = -(1/12)+(pi/6)*i; K = 2; n = 0:40; x = K*exp(c*n); subplot(2,1,1);

stem(n,real(x)); xlabel('Time index n');ylabel('Amplitude'); title('Real part'); subplot(2,1,2); stem(n,imag(x)); xlabel('Time index n');ylabel('Amplitude'); title('Imaginary part');

Answers: Q1.6 The complex-valued exponential sequence generated by running Program P1_2 is shown below :

Q1.7

The parameter controlling the rate of growth or decay of this sequence is - El parametro C es el que controla si: C = 1 las partes real e imaginaria son senoidales, C < corresponden a secuencias senoidales multiplicadas por un exponencial decreciente y C>1 corresponden a secuencias senoidales multiplicadas por un exponencial creciente The parameter controlling the amplitude of this sequence is

la variable k

Q1.8

The result of changing the parameter

c to (1/12)+(pi/6)*i is la seal sinusoidal

empieza a crecer
Q1.9 The purpose of the operator The purpose of the operator Q1.10

realis mostrar solo la parte real de la ecuacin imag is mostrar solo la parte imaginaria de la ecuacin

The purpose of the command subplotis Generar una mayor cantidad de grficos en una ventana grafica de matlab

Q1.11

The real-valued exponential sequence generated by running Program P1_3 is shown below :

Q1.12

The parameter controlling the rate of growth or decay of this sequence is - Si a y k son reales podemos decir que: a>1 la magnitude de la seal crece exponencialmente, a<1 tenemos una exponencial decreciente The parameter controlling the amplitude of this sequence is

la constante k

Q1.13

The difference between the arithmetic operators ^ and

.^ is la diferencia est en que cuando se usa el punto, no debe sere scalar necesariamente, a diferencia de quitar el punto los valores deben ser escalares.

Q1.14

The sequence generated by running Program P1_3 with the parameter parameter K changed to 20 is shown below :

a changed to 0.9 and the

Q1.15

The length of this sequence is

La amplitud cambio a 20 con relacin a la anterior grfica, porque se

modific la constante K
It is controlled by the following MATLAB command line : a = 0.9; K = 20; x = K*a.^n; It can be changed to generate sequences with different lengths as follows (give an example command line and the corresponding length) : 0:35; a = 1.2; K = 0.20; K*a.^n; El anterior cdigo corresponde a una parte de programa P1_3 en donde si queremos variar la longitud de la seal solo cambiamos la variable n : 0:60; a = 1.2; K = 0.20; K*a.^n; Si graficamos esta funcin la longitud de la seal cambio a una longitud de 60, lo mismo pasa con la amplitud

n = x = n = x = K.

Q1.16

clf; n = 0:35; a = 1.2; K = 0.2; x = K*a.^n; b = 0.9; C = 20; y = C*b.^n; T = sum(x.^2 + y.^2) >> ej_sum T = 4.7777e+04

The energies of the real-valued exponential sequences Q1.14 and computed using the command sum are

x[n]generated in Q1.11 and

Project 1.3

Sinusoidal sequences

A copy of Program P1_4 is given below . % Program P1_4 % Generation of a sinusoidal sequence n = 0:40; f = 0.1; phase = 0; A = 1.5; arg = 2*pi*f*n - phase; x = A*cos(arg); clf; % Clear old graph stem(n,x); % Plot the generated sequence axis([0 40 -2 2]); grid; title('Sinusoidal Sequence'); xlabel('Time index n'); ylabel('Amplitude'); axis;

Answers: Q1.17 The sinusoidal sequence generated by running Program P1_4 is displayed below .

Q1.18 phase;

The frequency of this sequence is- 10 Hz It is controlled by the following MATLAB command line : f = 0.1; arg = 2*pi*f*n -

A sequence with new frequency _____ can be generated by the following command line : f

rand(1,1); 8

phase;

The parameter controlling the phase of this sequence is - phase = 0; arg = 2*pi*f*n The parameter controlling the amplitude of this sequence is- A = 1.5;

The period of this sequence is Q1.19 The length of this sequence is

- Periodo = 1/f = 10 - 1.5

It is controlled by the following MATLAB command line : A = 1.5; A sequence with new length _____ can be generated by the following command line : A = rand(1,1); The average power of the generated sinusoidal sequence is - arg = 2*pi*f*n The purpose of

Q1.20 phase; Q1.21

axis command is - Configurar el la ventana donde se ve el grafico en MaTlab, los valores corresponden a: Xmin, Xmax, Ymin, Ymax
The purpose of

grid command is - Generar la cuadricula en cada punto en el grafico en la

ventana de matlab
Q1.22 The modified Program P1_4 to generate a sinusoidal sequence of frequency 0.9 is given below along with the sequence generated by running it .

% Program P1_4 % Generation of a sinusoidal sequence n = 0:40; f = 0.9; Frecuencia=1/f phase = 0; A = 1.5; arg = 2*pi*f*n - phase; x = A*cos(arg); clf; % Clear old graph stem(n,x); % Plot the generated sequence axis([0 40 -2 2]); grid; title('Sinusoidal Sequence'); xlabel('Time index n'); ylabel('Amplitude'); axis;

A comparison of this new sequence with the one generated in Question Q1.17 shows

- Es

prcticamente la misma seal generada anteriormente, pero con un periodo de 1.111


A sinusoidal sequence of frequency 1.1 generated by modifying Program P1_4 is shown below.

10

A comparison of this new sequence with the one generated in Question Q1.17 shows

No se distinguen los cambios, except por el periodo = 0.9091


Q1.23 The sinusoidal sequence of length 50, frequency 0.08, amplitude 2.5, and phase shift of 90 degrees generated by modifying Program P1_4 is displayed below .

The period of this sequence is Q1.24

- 12.5000 plot command, the plot obtained

By replacing the stem command in Program P1_4 with the is as shown below:

11

The difference between the new plot and the one generated in Question Q1.17 is

- El

comando plot genera graficas continuas


Q1.25 By replacing the stem command in Program P1_4 with the stairs command the plot obtained is as shown below :

The difference between the new plot and those generated in Questions Q1.17 and Q1.24 is- El comando stairs muestra la seal como si fuse una seal digital.

12

Project 1.4 Answers: Q1.26

Random signals

The MATLAB program to generate and display a random signal of length 100 with elements uniformly distributed in the interval [2, 2] is given below along with the plot of the random sequence generated by running the program :

sig_length = 100; r = -2 + 4.*rand(100,1); plot(1:sig_length,r); grid;

Q1.27

The MATLAB program to generate and display a Gaussian random signal of length 75 with elements normally distributed with zero mean and a variance of 3 is given below along with the plot of the random sequence generated by running the program :

x = 0:0.1:75; y = gaussmf(x,[3 20]); plot(x,y) xlabel('gaussmf, P=[3 20]')

13

Q1.28

The MATLAB program to generate and display five sample sequences of a random si nusoidal signal of length 31

{X[n]} = {A*cos(on + )}
where the amplitudeA and the phase are statistically independent random variables with uniform probability distribution in the range 0 A 4 for the amplitude and in the range 0 2 for the phase is given below. Also shown are five sample sequences generated by running this program five different times . clf; f1 = 0.50; f2 = 0.60; f3 = 0.70; f4 = 0.050; f5 = 0.080; n = 0:31; A = 4*rand(1,1); r1 = 2*pi*rand(1,1); T1 = A*cos(2*pi*f1*n+r1); plot(n,T1,'R') hold on; T1 = A*cos(2*pi*f2*n+r1); plot(n,T1,'Y') hold on; T1=A*cos(2*pi*f3*n+r1); plot(n,T1,'K') hold on; T1=A*cos(2*pi*f4*n+r1); plot(n,T1,'B') hold on; T1=A*cos(2*pi*f5*n+r1); plot(n,T1,'G') legend( 'S1[R] ','S2[Y] ','S3[K] ','S4[B] ','S5[G] '); hold off;

14

1.2

SIMPLE OPERATIONS ON SEQUENCES Signal Smoothing

Project 1.5

A copy of Program P1_5 is given below . % Program P1_5 % Signal Smoothing by Averaging clf; R = 51; d = 0.8*(rand(R,1) - 0.5); % Generate random noise m = 0:R-1; s = 2*m.*(0.9.^m); % Generate uncorrupted signal x = s + d'; % Generate noise corrupted signal subplot(2,1,1); plot(m,d','r-',m,s,'g--',m,x,'b-.'); xlabel('Time index n');ylabel('Amplitude'); legend('d[n] ','s[n] ','x[n] '); x1 = [0 0 x];x2 = [0 x 0];x3 = [x 0 0]; y = (x1 + x2 + x3)/3; subplot(2,1,2); plot(m,y(2:R+1),'r-',m,s,'g--'); legend( 'y[n] ','s[n] '); xlabel('Time index n');ylabel('Amplitude');

Answers: Q1.29 The signals generated by running Program P1_5 are displayed below :

15

Q1.30

The uncorrupted signal The additive noise

s[n]is - Es la seal que debemos transmitir

d[n]is - Es una seal aleatoria

Q1.31

The statement signal because

x = s + d CAN / CANNOT be used to generate the noise corrupted - No se puede usar por que nos sale con cierta distorsion(Ruido)

Q1.32

The relations between the signalsx1, x2, andx3, and the signal xare - Son los vectores(X1, X2, X3) son los que muestrean la seal (3 vectores, se puede decir que son un tipo de filtro) y X es la seal resultante el promedio The purpose of thelegendcommand is distintas seales por color y tipo de lnea. Generation of Complex Signals

Q1.33

- Sirve para poder identificar en un mismo grafico a las

Project 1.6

A copy of Program P1_6 is given below . % Program P1_6 % Generation of amplitude modulated sequence clf; n = 0:100; m = 0.4;fH = 0.1; fL = 0.01; xH = sin(2*pi*fH*n); xL = sin(2*pi*fL*n); y = (1+m*xL).*xH; stem(n,y);grid; xlabel('Time index n');ylabel('Amplitude');

Answers:

16

Q1.34

The amplitude modulated signals y[n] generated by running Program P1_6 for various values of the frequencies of the carrier signal xH[n] and the modulating signal xL[n], and various values of the modulation index m are shown below :

Q1.35

The difference between the arithmetic operators

* and .* is la diferencia esta en que si solo se utilizer el asterisco solo se podran multiplicar numeros escalares, en cambio si utilizamos un punto, se podra utilizar vectores.

A copy of Program P1_7 is given below . % Program P1_7 % Generation of a swept frequency sinusoidal sequence n = 0:100; a = pi/2/100; b = 0; arg = a*n.*n + b*n; x = cos(arg); clf; stem(n, x); axis([0,100,-1.5,1.5]); title('Swept-Frequency Sinusoidal Signal'); xlabel('Time index n'); ylabel('Amplitude'); grid; axis; Answers: Q1.36 The swept-frequency sinusoidal sequence displayed below.

x[n] generated by running Program P1_7 is

17

Q1.37 Q1.38

The minimum and maximum frequencies of this signal are

ayb

The Program 1_7 modified to generate a swept sinusoidal signal with a minimum frequency of 0.1 and a maximum frequency of 0.3 is given below :

% Program P1_7 % Generation of a swept frequency sinusoidal sequence n = 3:10; a = pi/2/100; b = 0; arg = a*n.*n + b*n; x = cos(arg); clf; stem(n, x); axis([3,10,-1.5,1.5]); title('Swept-Frequency Sinusoidal Signal'); xlabel('Time index n'); ylabel('Amplitude'); grid; axis;

18

1.3 Q1.39

WORKSPACE INFORMATION The information displayed in the command window as a result of the

who command is - lista

las variables a ans arg b


Q1.40

x whos command

The information displayed in the command window as a result of the is Muestra la informacion de cada variable.

Name a ans arg b n x

Size 1x1 1x4 1x101 1x1 1x101 1x101

Bytes Class 8 double 32 double 808 double 8 double 808 double 808 double

Attributes

19

1.4

OTHER TYPES OF SIGNALS (Optional) Squarewave and Sawtooth Signals

Project 1.8 Answer: Q1.41

MATLAB programs to generate the square-wave and the sawtooth wave sequences of the type shown in Figures 1.1 and 1.2 are given below along with the sequences generated by running these programs :

n = 0:100; x = square(n); stem(n, x); axis([0,100,-1.5,1.5]); title('Swept-Frequency Sinusoidal Signal'); xlabel('Time index n'); ylabel('Amplitude'); grid; axis;

n = 0:100; x = sawtooth(n); stem(n, x); axis([0,100,-1.5,1.5]); title('Swept-Frequency Sinusoidal Signal'); xlabel('Time index n'); ylabel('Amplitude'); grid; axis;

20

Date: 26/08/2013

Signature: DSP

21

You might also like