0% found this document useful (0 votes)
79 views13 pages

Lab 9

The document describes a lab experiment involving the generation and manipulation of various signal sequences. It generates unit step sequences, unit sample sequences, delayed sequences, cosine waves, exponential waves, and interpolated/decimated signals. For each task, it provides the MATLAB code used to generate the relevant signals and displays the output graphs.

Uploaded by

HassanFaraz
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)
79 views13 pages

Lab 9

The document describes a lab experiment involving the generation and manipulation of various signal sequences. It generates unit step sequences, unit sample sequences, delayed sequences, cosine waves, exponential waves, and interpolated/decimated signals. For each task, it provides the MATLAB code used to generate the relevant signals and displays the output graphs.

Uploaded by

HassanFaraz
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/ 13

LAB # 9:

“Generation of Different Sequences Along with Basic Signal


Operations and Implementation of Running Average Filter”
TASK 1:
Generate unit step sequence:

x[n] = [ -1 for n < 0, 0 for n =0, 1 for n > 0]

[unit step sequence is generated by using ones()]

n = -10:10;

seq=[-ones(1,10) 0 ones(1,10)];

stem(seq),grid on

xlabel('Sample Number')

ylabel('Signal Amplitude')

%axis([-10 10 -1 1])

title('Unit Step Sequence')


Unit Step Sequence
1

0.8

0.6

0.4
Signal Amplitude

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 5 10 15 20 25
Sample Number

TASK 2:
Generate unit sample sequence; create a vector from -10 to 20

[Unit sample sequence is generated by using zeroes()]

n = -10:20;

seq = [zeros(1,10) 1 zeros(1,20)];

stem(n,seq,'linewidth',3),grid on

xlabel('Time index seq')

ylabel('Amplitude')

title('Unit Sample Sequence')

axis([-10 20 0 2])
Unit Sample Sequence
2

1.8

1.6

1.4

1.2
Amplitude

0.8

0.6

0.4

0.2

0
-10 -5 0 5 10 15 20
Time index seq

TASK 3:
Delay a sequence. Sample code delays a sequence by 10 samples:

seq = 1:100;

subplot(2,1,1)

stem(seq),grid

axis([0 100 0 200])

xlabel('Time index seq')

ylabel('Amplitude')

title('Sequence');

seq_delay=[zeros(1,10) seq];

subplot(2,1,2)
stem(seq_delay),grid

axis([0 100 0 200])

xlabel('Time index seq')

ylabel('Amplitude')

title('Delayed Sequence')

Sequence
200

150
Amplitude

100

50

0
0 10 20 30 40 50 60 70 80 90 100
Time index seq
Delayed Sequence
200

150
Amplitude

100

50

0
0 10 20 30 40 50 60 70 80 90 100
Time index seq
Sequence
200

150
Amplitude

100

50

0
0 10 20 30 40 50 60 70 80 90 100
Time index seq
Delayed Sequence
200

150
Amplitude

100

50

0
0 10 20 30 40 50 60 70 80 90 100
Time index seq

TASK 4:
Generate the cosine wave and its flipped wave.

n = -1:.001:1;

Y= 5*cos(2*pi*1*n);

subplot(2,1,1)

plot(n,Y,'g','linewidth',2),grid on

xlabel('time')

ylabel('Signal Amplitude')

title('Original cosine Wave')


subplot(2,1,2)

plot(n,-Y,'r','linewidth',2),grid on

xlabel('Time')

ylabel('Signal Amplitude');

title('Flipped cosine Wave');

Original cosine Wave


5
Signal Amplitude

-5
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
time
Flipped cosine Wave
5
Signal Amplitude

-5
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
Time

TASK 5:
Generate the exponential wave and its flipped wave.

n=-1:0.001:1;

Y=5*exp(i*n*pi/4);

subplot(2,1,1)
plot(n,Y,'g','linewidth',2),grid on

%axis([-1 1 3.5 5])

xlabel('time');

ylabel('Signal Amplitude')

title('Original Wave')

subplot(2,1,2)

plot(n,-Y,'r','linewidth',2),grid on

%axis([-1 1 -3.5 -5])

xlabel('Time')

ylabel('Signal Amplitude')

title('Flipped Wave')

Original Wave
5
Signal Amplitude

4.5

3.5
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
time
Flipped Wave
-3.5
Signal Amplitude

-4

-4.5

-5
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
Time
TASK 6:
Generate the flipped wave of the following expression:

X = 2*[n]+5*[n-1]+8*[n-2]+4*[n-3]+3*[n-4]

n = 0:0.1:4;

X = 2*[n]+5*[n-1]+8*[n-2]+4*[n-3]+3*[n-4];

subplot(2,1,1)

stem(n,X,'g','linewidth',1.5),grid on

xlabel('time')

ylabel('signal amplitude')

%axis([0 4 -50 50 ])

title('Original wave')

subplot(2,1,2)

stem(n,-X,'r','linewidth',1.5),grid on

xlabel('time')

ylabel('signal amplitude')

%axis([0 4 -50 50 ])

title('Flipped Wave')
Original wave
50

signal amplitude

-50
0 0.5 1 1.5 2 2.5 3 3.5 4
time
Flipped Wave
50
signal amplitude

-50
0 0.5 1 1.5 2 2.5 3 3.5 4
time

TASK 7:
Generate a scaled and flipped sequence of the following expression:

Y=5*exp(i*n*pi/4)

n=1:0.2:7;

Y=5*exp(i*n*pi/4);

S=2;

subplot(2,1,1),grid on

stem(n,Y,'g','linewidth',1),grid on

%axis([1 7 -5 5])

xlabel('time')

ylabel('signal amplitude')
title('Original wave')

subplot(2,1,2)

stem(-n,-1*S*Y,'r','linewidth',1),grid on

%axis([1 7 -5 5])

xlabel('time')

ylabel('signal amplitude')

title('scaled and flipped wave')

Original wave
5
signal amplitude

-5
1 2 3 4 5 6 7
time
scaled and flipped wave
10
signal amplitude

-5

-10
-7 -6 -5 -4 -3 -2 -1
time
TASK 8:
Interpolate a signal given below by a factor of four:

x1 = sin(2pi(2)t)

t= -2:.001:2;

x = sin(2*pi*2*n);

x1 = interp(x,4);

subplot(2,1,1)

plot(x),grid on

xlabel('Sample Number')

ylabel('Signal Amplitude')

title('Original signal')

subplot(2,1,2)

plot(x1),grid on

xlabel('Sample Number')

ylabel('Signal Amplitude')

title('Interpolated signal')
Original signal
1
Signal Amplitude
0.5

-0.5

-1
0 500 1000 1500 2000 2500 3000 3500 4000 4500
Sample Number
Interpolated signal
2
Signal Amplitude

-1

-2
0 2000 4000 6000 8000 10000 12000 14000 16000 18000
Sample Number

TASK 9:
Decimate a signal given below by a factor of two:

y1 = sin(2pi(2)t)

t = -2:.001:2;

y1 = sin(2*pi*2*t);

y2 = decimate(y1,2);

subplot(2,1,1)

plot(y1),grid on

xlabel('Sample Number')

ylabel('Signal Amplitude')
title('Original signal')

subplot(2,1,2)

plot(y2),grid on

xlabel('Sample Number')

ylabel('Signal Amplitude')

title('Decimated signal')

Original signal
1
Signal Amplitude

0.5

-0.5

-1
0 500 1000 1500 2000 2500 3000 3500 4000 4500
Sample Number
Decimated signal
1
Signal Amplitude

0.5

-0.5

-1
0 500 1000 1500 2000 2500
Sample Number

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy