DATE:28/08/2013 EXPERIMENT 3: Generation of Discrete Sequences
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
2.5
4.5
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
3.5
4.5
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
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');
amplitude
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
0.8
0.6
0.4
0.2
-0.2
-0.4 -5
-4
-3
-2
-1
0 time
-1
-2
-3
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
-1
-2
-3 -1
-0.8
-0.6
-0.4
-0.2
0.2
0.4
0.6
0.8