You are on page 1of 12

Departament of Electrical and Computer Engineering Universidad de Puerto Rico - Mayagez

Signals and Systems Assignment 1

by Rubn J. Prez Rivera 843-06-6160

for Prof. Vidya Manian Department of Electrical and Computer Engineering Universidad de Puerto Rico en Mayagez manian@ece.uprm.edu

February 22, 2013

Assignment 1: Basic Signal Generation Due Date: February 22 2013

Introduction: This work introduces students to signal generation. This document has to be submitted with the following modifications: 1. Send copy of the document via email. 2. Write name, student ID number and date of submission in first page. 3. Show mathematical development (if any) of the results you have presented. 4. Answer the questions below each question.

Problem No. P1.1: Generation of a unit simple sequence % Program 1-1 % Generation of a unit sample sequence clf; %generate a vector from -10 to 20 n=-10:20; %generate the unit sample sequence delta = [zeros(1,10) 1 zeros(1,20)]; stem(n,delta); xlabel('Time index n'); ylabel('Amplitude'); title('Unit Sample Sequence'); axis([-10 20 0 1.2]); Questions: 1. Generate the unit sample sequence u[n] and display it.

Unit Sample Sequence

0.8 Amplitude

0.6

0.4

0.2

0 -10

-5

5 Time index n

10

15

20

2. Modify the program to generate a delayed unit sample sequence ud[n] with a delay of 11. Run the program and display result.

% Program 1-1 % Generation of a unit sample sequence clf; %generate a vector from -10 to 20 n=-10:20; %generate the unit sample sequence delta = [zeros(1,21) 1 zeros(1,9)]; stem(n,delta); xlabel('Time index n'); ylabel('Amplitude'); title('Unit Sample Sequence'); axis([-10 20 0 1.2]);
Unit Sample Sequence

0.8 Amplitude

0.6

0.4

0.2

0 -10

-5

5 Time index n

10

15

20

3. Modify the program to generate a unit sample sequence s[n]. Run the program and display result. % Program 1-1

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

Unit Sample Sequence

0.8 Amplitude

0.6

0.4

0.2

0 -10

-5

5 Time index n

10

15

20

4. Modify the program to generate a delayed unit step sequence sd[n] with an advance of 7 samples. Run the program and display result. % Program 1-1 % Generation of a unit sample sequence clf;

%generate a vector from -10 to 20 n=-10:20; %generate the unit sample sequence u = [ones(1,3) 1 zeros(1,27)]; stem(n,u); xlabel('Time index n'); ylabel('Amplitude'); title('Unit Sample Sequence'); axis([-10 20 0 1.2]);
Unit Sample Sequence

0.8 Amplitude

0.6

0.4

0.2

0 -10

-5

5 Time index n

10

15

20

Problem No. P1.2: Generation of a complex exponential sequence % Program 1-2 % Generation of a complex exponential sequence

clf; c=-(1/21)+(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'); Questions: 1. Run the program and generate the sequence.
Real part 2 1 Amplitude 0 -1 -2

10

15

20 25 Time index n Imaginary part

30

35

40

2 1 Amplitude 0 -1 -2

10

15

20 25 Time index n

30

35

40

2. What will happen if parameter c is changed to (1/12)+(pi/6)*i?

Real part 50

Amplitude

-50

10

15

20 25 Time index n Imaginary part

30

35

40

100

Amplitude

50

-50

10

15

20 25 Time index n

30

35

40

It reverses the signal and magnifies its amplitude.

3. Write a program to generate a real exponential seuqnce, run the program and generate the sequence.

n=40; a=.5; t=0:1:n-1; y=exp(a*t); plot(t,y); ylabel('Amplitude'); xlabel('Time Index'); title('Exponential Signal');
x 10
8

Exponential Signal

2.5

2 Amplitude

1.5

0.5

10

15

20 Time Index

25

30

35

40

5. Use the command sum(s.*s) to compute the energy of a real sequence s[n] stored as a vector s. Evaluate the energy of the real-valued exponential sequence x[n] generated in question 3. sum(y.*y) ans = 1.3699e+017 Problem No. P1.3: Generation of a sinusoidal sequence % Program 1-3

% Generation of a sinusoidal sequence clf; n=0:40; f=0.1; phase=0; A=1.5; arg=2*pi*f*n - phase; x=A*cos(arg) clf; stem(n,x); axis([0 40 -2 2]); grid; title('Sinusoidal sequence') xlabel('Time index n'); ylabel('Amplitude'); axis;

Questions: 1.Run the program and display the sequence.


Sinusoidal sequence 2 1.5 1 0.5 Amplitude 0 -0.5 -1 -1.5 -2

10

15

20 T ime index n

25

30

35

40

2. What is the frequency of this signal and how can it be changed. Which parameter controls phase.

Frequency is 0.1Hz. It can be changed by changing the frequency in the program. The parameter that controls phase is phase=0in the program 3. Modify the program to generate a sinusoidal sequence of frequency 0.9 and display it. % Program 1-3 % Generation of a sinusoidal sequence clf; n=0:40; f=0.9; phase=0; A=1.5; arg=2*pi*f*n - phase; x=A*cos(arg) clf; stem(n,x); axis([0 40 -2 2]); grid; title('Sinusoidal sequence') xlabel('Time index n'); ylabel('Amplitude'); axis;
S u id l se u n in so a q e ce 2 1 .5 1 0 .5 Amplitude 0 -0 .5 -1 -1 .5 -2

1 0

1 5

2 0 T ein e n im d x

2 5

3 0

3 5

4 0

4. Modify the program to genrate a sinusoidal sequence of length 50, frequency 0.08, amplitude 2.5 and phase shift 90degress and display it. % Program 1-3

% Generation of a sinusoidal sequence clf; n=0:50; f=0.08; phase=90; A=2.5; arg=2*pi*f*n - phase; x=A*cos(arg) clf; stem(n,x); axis([0 50 -2.5 2.5]); grid; title('Sinusoidal sequence') xlabel('Time index n'); ylabel('Amplitude'); axis;
Sinusoidal sequence 2.5 2 1.5 1 0.5 Amplitude 0 -0.5 -1 -1.5 -2 -2.5

10

15

20 25 30 Time index n

35

40

45

50

You might also like