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

DATE:28/08/2013 EXPERIMENT 3: Generation of Discrete Sequences

This document contains descriptions and MATLAB code for generating several types of discrete sequences and signals, including: 1) Computing the cross-correlation of two sequences to find the lag between them. 2) Generating complex exponential sequences using real and imaginary exponents. 3) Producing a real exponential sequence based on an input argument and gain constant. 4) Computing the autocorrelation of a noise-corrupted sinusoidal sequence. 5) Creating a discrete-time sine wave based on input frequency and sampling frequency.

Uploaded by

Mukul Shahi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

DATE:28/08/2013 EXPERIMENT 3: Generation of Discrete Sequences

This document contains descriptions and MATLAB code for generating several types of discrete sequences and signals, including: 1) Computing the cross-correlation of two sequences to find the lag between them. 2) Generating complex exponential sequences using real and imaginary exponents. 3) Producing a real exponential sequence based on an input argument and gain constant. 4) Computing the autocorrelation of a noise-corrupted sinusoidal sequence. 5) Creating a discrete-time sine wave based on input frequency and sampling frequency.

Uploaded by

Mukul Shahi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

DATE:28/08/2013 EXPERIMENT 3: Generation of Discrete Sequences :

(1)Computation of cross correlation sequence x=input('type in the reference sequence='); y=input('type in the second sequence='); n1=length(x)-1;n2=length(y)-1; r=conv(x,fliplr(y)); k=(-n1):n2; stem(k,r); xlabel('Lag Index');ylabel('Amplitude'); v=axis; axis([-n1 n2 v(3:end)]); type in the reference sequence=[1 3 4 7] type in the second sequence=[2 4 2 7]
80 70 60 50

Amplitude

40 30 20 10 0 -3

-2

-1

0 Lag Index

(2) Generation of complex exponential sequence: a=input('type in real exoponent='); b=input('type in imaginary exoponent='); c=a+b*i; K=input('type in the gain constant='); N=input('type in length of sequence='); n=1:N; x=K*exp(c*n); stem(n,real(x)); xlabel('time index n'); ylabel('amplitude'); title('real part'); disp('PRESS RETURN for imaginary part'); pause stem(n,imag(x)); xlabel('time index n');ylabel('amplitude'); title('imaginary part'); type type type type in in in in real exoponent=6 imaginary exoponent=5 the gain constant=3 length of sequence=5
3.5 3 2.5 2 x 10
13

real part

amplitude

1.5 1 0.5 0 -0.5

1.5

2.5

3 3.5 time index n

4.5

(3) Generation of real exponential sequence


=4
6000

a=input('type in argument='); K=input('type in the gain constant='); N=input('type in the length of sequence='); n=0:N; x=K*a.^n; stem(n,x); xlabel('time index n'); ylabel('amplitude'); title(['\alpha=',num2str(a)]);

5000

4000

amplitude

3000

2000

1000

type in argument=4 type in the gain constant=5 type in the length of sequence=5

0.5

1.5

2.5 3 time index n

3.5

4.5

(4)Computation of Autocorrealtion of a Noise corrupted sinusoidal sequence

60

40

N=96;n=1:N; x=cos(pi*0.25*n); d=rand(1,N)-0.5; y=x+d; r=conv(y,fliplr(y)); k=-28:28; stem(k,r(68:124)); xlabel('lag index'); ylabel('amplitude'); (5) To Generation Discrete sine wave :
1 0.8

20
amplitude

-20

-40

-60 -30

-20

-10

0 lag index

10

20

30

discrete time sine wave

clc; disp('discrete tine sine wave');disp(''); N=input('enter the no. of samples='); F=input('enter the signal frequency F(Hz)'); Fs=input('enter the sampling frequency Fs(Hz)='); n=1:N;f=F/Fs; x=sin(2*pi*f*n); disp('samples of discrete sine wave are='); disp(x);stem(x); t=[0 0];q=[0 N];line(q,t); xlabel('sample n'); ylabel('amplitude'); title('discrete time sine wave');

0.6 0.4 0.2

amplitude

0 -0.2 -0.4 -0.6 -0.8 -1

0.5

1.5

2 sample n

2.5

3.5

discrete tine sine wave enter the no. of samples=4 enter the signal frequency F(Hz)20 enter the sampling frequency Fs(Hz)=30 samples of discrete sine wave are= -0.8660 0.8660 -0.0000 -0.8660
e1) Generate a sinc function :
sinc function 1

amplitude

x = linspace(-5,5); y = sinc(x); plot(x,y) xlabel('time'); ylabel('amplitude'); title('sinc function');

0.8

0.6

0.4

0.2

-0.2

-0.4 -5

-4

-3

-2

-1

0 time

e2) Generate a triangular function:


3

-1

-2

-3

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

A=2; t=0:0.0005:1; x=A*sawtooth(2*pi*2*t,0.50); plot(t,x); grid axis([0 1 -3 3]);

e3) Generate a rectangular function :


3

-1

-2

-3 -1

-0.8

-0.6

-0.4

-0.2

0.2

0.4

0.6

0.8

x=-3:0.001:3; y=rectpuls(x); plot(x,y) axis([-1 1 -3 3]);

You might also like