Professional Documents
Culture Documents
NMK31003 DSP Lab 1 Module For Sem 2 2023 2024-Scilab
NMK31003 DSP Lab 1 Module For Sem 2 2023 2024-Scilab
NMK31003 DSP Lab 1 Module For Sem 2 2023 2024-Scilab
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
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