Professional Documents
Culture Documents
Student Name:
Reg. No. :
Date :
Signature :
Objectives:
Preparation:
Procedure:
Save the file in current folder, LAB1, with the name impseq.m
Try the following commands in command window and check the results:
impseq(3,0,10)
impseq(0,0,10)
Ref: Ingle and Proakis, Digital Signal Processing using Matlab, p.7 Page: 1
Step2: Unit step sequence
Save the file in current folder, LAB1, with the name stepseq.m
Try the following commands in command window and check the results:
stepseq(3,0,10)
stepseq(5,0,10)
1) Uniform random sequence, we use Matlab function rand(1,N) which generates N samples between [0,1] of
equal probability.
2) Gaussian random sequence, we use Matlab function randn(1,N) which generates N samples of mean zero
and variance 1.
Generate a Gaussian random sequence of mean = 10, and variance1 = 2, variance2 = 6 , number of
samples = 100
n= [-20:30];
SD1 = sqrt(2); % Standard Deviation
SD2 = sqrt(6); % Standard Deviation
M = 10;
X1 = M + SD1 * randn(1,100);
X2 = M + SD2 * randn(1,100);
Y1= normpdf(n,M,SD1);
Y2= normpdf(n,M,SD2);
subplot(2,2,1); stem(X1);
subplot(2,2,2); stem(X2);
subplot(2,2,3); stem(n,Y1);
subplot(2,2,4); stem(n,Y2);
Ref: Ingle and Proakis, Digital Signal Processing using Matlab, p.7 Page: 2
Q) Compare the figures and give us your note.
end
Save the file in current folder, LAB1, with the name sigadd.m
Try the following commands in command window and check the results:
x1 = [4 5 3 1 2]
n1 = [-1 0 1 2 3]
x2 = [1 3 2 7 5 2 3]
n2 = [0 1 2 3 4 5 6]
[y,n] = sigadd(x1,n1,x2,n2)
end
Save the file in current folder, LAB1, with the name sigmult.m
you can apply the same commands in the command window to check the function.
Ref: Ingle and Proakis, Digital Signal Processing using Matlab, p.7 Page: 3
Step3: Signal shifting y(n) = x(n-k) .
In this operation each sample in x(n) is shifted by amount k to obtain shifted sequence y(n)
Please, note that the shifting has no effect on x vector, but the vector n is changed by adding k to each element.
end
Save the file in current folder, LAB1, with the name sigshift.m
n = 0:100;
Fs = 10;
t = n * (1/fs);
x = cos(2.*pi.*t);
subplot(2,1,1);
stem(n,x);
[y,n] = sigshift(x,n,5); % shift by k = 5
subplot(2,1,2);
stem(n,y);
Step4: Signal Folding, in this operation each sample of x(n) is flipped around n = 0 to obtain a folded sequence
y(n).
Save the file in current folder, LAB1, with the name sigfold.m
x = [0 1 2 3 4 5];
n = [0 1 2 3 4 5];
stem(n,x);
hold on;
[y,n] = sigfold(x,n);
stem(n,y)
axis([-5 5 0 10]);
Ref: Ingle and Proakis, Digital Signal Processing using Matlab, p.7 Page: 4
Q) Describe y(n) with respect to x(n) in time domain?
Conclusion:
Homework:
After you have completed LAB1, you had the following Matlab function in LAB1 folder:
(impseq, stepseq, sigadd, sigmult, sigshift, and sigfold), use them to obtain the following signals:
Ref: Ingle and Proakis, Digital Signal Processing using Matlab, p.7 Page: 5