NMK31003 DSP Lab 1 Module For Sem 2 2023 2024-Scilab

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Universiti Malaysia Perlis

NMK31003: DIGITAL SIGNAL PROCESSING


LABORATORY MODULES
SEMESTER II SESSION 2023/2024

LAB 1:
TIME-DOMAIN REPRESENTATION OF
SIGNALS AND SYSTEMS

1
OBJECTIVES:

(a) To get acquainted with SCILAB in digital signal processing (DSP) simulations.
(b) To use SCILAB in time-domain representation of signals and systems.
(c) To gain the ability in deploying SCILAB in doing operations on sequence e.g. addition,
product, sampling, etc.

Introduction to SCILAB

Currently SCILAB is developed by the SCILAB Consortium, which was created by INRIA
(French National Institute for Research in Computer Science and Control). SCILAB is a
programming language associated with a rich collection of numerical algorithms covering
many aspects of scientific computing problems include the digital signal processing (DSP)
areas. Therefore, the SCILAB is concerned with the mathematical representation of the signal
and the algorithmic operation carried out on it to extract the information present.

In the NMK31003 course, students will integrate SCILAB with traditional topics in DSP.
Through this, students can explore difficult topics and solve problems to gain insight. Many
problems or design algorithms in DSP require considerable computation. In fact, SCILAB
provides a convenient mathematical software tool so that many scenarios can be tried or
simulated with ease. Such an approach can enhance the learning process.

Technically, high-level computer languages such as SCILAB are designed to process ordered
sequences of elements, that is, variables, vectors, and matrices. These three terms form a
hierarchy in the sense that:
 A variable is a single element (integer, real, or complex), e.g. x = 4;
 A vector is an ordered sequence of variables, e.g. y = [2,3,4];
 A matrix is an ordered sequence of vectors, e.g. z = [1 2 3; 4 5 6];

2
Example:
1. Consider the following sinusoidal function
x (t )=3 cos ( 3 πt ) +5 sin (5 πt ) ,−2 ≤t ≤ 2.
Using SCILAB, we want to plot the x (t ) .
The code:

3
2. Generate the stem plot x [ n ] =5 cos ( 0.1 πn+ 0.5 π )+5 cos ( 0.3 πn ) ,−30 ≤n ≤ 30 using
SCILAB. The script:

4
3. Generate the sinusoidal function in Example 1 with −1 ≤t ≤1 above and its 20
samples, N=20 combined plots. The SCILAB script:

5
Exercise in Lab

1. Consider the following sinusoidal function and its domain:


1
x (t )=cos ( πt ) +2 sin ( 4 πt )+ cos ( 8 πt ) , 0≤ t ≤ 1.
4
a. Generate the x (t ) plot. (Hint: The interval of domain increment is 0.01)
b. Generate the x [n] stem plot with the total number of 10 samples, N=10 .
c. Generate both the x (t ) and its x [n] generated in Exercise 1(b) combined plots.
d. Generate the x [n] stem plot with the total number of 20 samples, N=20.
e. Generate both the x (t ) and its x [n] generated in Exercise 1(d) combined plots.
f. Generate the x[n] stem plot with the total number of 30 samples, N=30.
g. Generate both the x (t ) and its x [n] generated in Exercise 1(f) combined plots.
h. Please analyse briefly the changes of sampling process as N increasing,
choose which one of the three sample numbers above has relatively the “best”
output, and justify your scientific reason.

2. Write a SCILAB function sigSub(x1, n1, x2, n2), which implements the
signal subtraction ySub[n] = x1[n1] - x2[n2] where the sequences
x1[n1] is defined over the index sequence n1, and the sequence x2[n2] is defined
over n2. Evaluate your .m code with the following sequences:
x1 = [1, -2, 0, 3, 2, 0, 3, 4, 1, 0, 3] for –5 ≤ n1 ≤ 5
x2 = [-2, 3, 4, -4, 0, -1, 5, 3] for –2 ≤ n2 ≤ 5
Hint: The SCILAB commands min(x) and max(x) are helpful.
Then, using the subplot command, please generate the ySub, x1, and x2 plots.
3. Modify the above SCILAB function to be sigAdd(x1, n1, x2, n2) and
additional function sigMulti(x1, n1, x2, n2), which implements the signal
add as yAdd[n] = x1[n1] + x2 [n2] and signal product as yMulti[n]
= x1[n1] .* x2 [n2]. Test your code with the same sequence as in the
Exercise 2. Then, using the subplot command, please generate the x1, x2, yAdd,
and yMulti plots.

6
7

You might also like