Professional Documents
Culture Documents
LAB1
LAB1
Student Name:
Reg. No. :
Date :
Signature :
Objectives:
1) Representing discrete time signals in Matlab.
2) Writing Matlab functions for elementary, impulse & step functions.
3) Applying Signal operations.
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)
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.
Generate a Gaussian random sequence of mean = 10, and variance = 2, number of samples = 100
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.
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
Try the following commands in command window:
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]);
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: