DSP - Manual Part
DSP - Manual Part
program’ is a vector containing the ASCII codes of the characters inside the quotation marks.
Any text following a percent symbol % denotes a comment and is not treated as a program
statement.
The colon symbol: has many different applications in MATLAB. It is used to generate vectors,
subscript matrices, and perform iterations of a block of commands. For example,
All arithmetic operations in MATLAB are performed in double precision. However, different
formats can be used to display the result of such operations in the Command window. If all
results are exact integers, they are displayed as such without any decimal points. If one or more
data elements are not integers, the results can be displayed with various precision. Format short
displays five significant decimal digits and is the default format. Format short e displays five
significant decimal digits with two positive or negative decimal exponents. Format long shows
results in 15 significant decimal digits, while format long e adds two positive or negative decimal
exponents to 15 significant decimal digits. There are three other formats for displaying results.
However, these are not that useful in signal processing applications.
Graphics
MATLAB includes high-level graphics capability for displaying the results of a computation. In
most situations, we shall be concerned with two-dimensional (2-D) graphics and will use three-
dimensional (3-D) graphics in some special cases. For 2-D graphics, plotting can be done in
various forms with either linear or logarithmic scales for one or both axes of the plots. Grid lines
can be added to the plots along with labels for the two axes and a title on
top of the plot. Text can be placed anywhere on the graph using a mouse or specifying the
starting position through commands in the program. Moreover, by including appropriate symbols
in the argument of the plotting command, specific line styles, plot symbols, and colors can be
displayed in the graph. For 3-D data, plotting can also be done in various forms with either linear
or logarithmic scales for one or two or all three axes of the plots. For example, lines and points
can be plotted in three dimensions. Contour plots, 3-D perspective plots, surface plots,
pseudocolor
MAT-Files
Data generated by a MATLAB program can be saved as a binary file, called a MAT-file, for
later use. For example, the noisy data generated by executing the program lowpass.m of the
previous section can be saved using the command save noise.mat data Later it can be retrieved
using the command load noise for use in another MATLAB session. The data can also be saved
in ASCII form. For example, after execution of the program
lowpass.m, we can generate a 2×11 matrix containing the noisy data and the smoothed data
using the command
result = [noise; z];
and then save the matrix result in ASCII form using the command save tempo.dat result –ascii.
The stored data can later be retrieved using the command load tempo
Printing
To develop a hardcopy version of the current Figure window, the command print can be used.
There are many versions of this command. See the MathWorks Online Documentation [Mat05]
for details. In a PC or a Mac environment, a figure can also be copied to the clipboard and then
inserted into a word processing document. This approach permits generating a smaller size figure
and also pasting the figure on to a text.
Experiment No. 1
Aim: Program to generate discrete time signals: unit impulse, unit step, sine, cosine, ramp
and exponential
Theory: In this experiment we learn how to generate in the time domain some basic discrete-
time signals in MATLAB.
A discrete-time signal is represented as a sequence of numbers, called samples. A sample value
of a typical discrete-time signal or sequence {x[n]} is denoted as x[n] with the argument n being
an integer in the range −∞ and ∞.
The discrete-time signal may be a finite length or an infinite length sequence. A finite length
(also called finite duration or finite extent) sequence is defined only for a finite time interval: N1
≤ n ≤ N2, where −∞ < N1 and N2 < ∞ with N2 ≥ N1. The length or duration N of the finite
length sequence is N = N2 − N1 + 1.
The unit sample sequence, often called the discrete-time impulse or the unit impulse, denoted by
δ[n], is defined by
δ[n] = 1, for n = 0,
0, for n ≠ 0.
Code:
Figures obtained:
(a) What is the difference between continuous time, discrete time and digital signals
(b) How are step and plot functions different
(c) Give relation between signum function and step function
(d) Give relationship between unit step and impulse function
(e) How will you justify that area under the curve for an impulse function is one.
(f) Differentiate between * and .* operator in MATLAB.
Experiment No.: 2
Theory:
Time Shifting: Time shifting of a signal results in time delay or time advance. y(n) =x(n-k)
implies that y(n) is obtained by time shifting the signal x(n) by k units. If k is positive, it is a
delay and the shift is to right and if it is negative, it is advance and shift is to left.
x(2n)= {3,1,3}
`
x(n/2) = { 0.4,0,3,2,0,1,0,2,0,3,0,4,0}
Code:
Figures obtained :