0% found this document useful (0 votes)
37 views4 pages

Discrete Time Signals and Signal Operations: DSP Lab#03

The document discusses discrete time signals and various operations that can be performed on discrete signals in MATLAB. It defines a discrete signal x(n) and explains that in MATLAB it requires two vectors, one for the sample values and one for the sample positions. It then provides examples of generating and plotting common signal types like unit sample sequences, unit step sequences, complex exponential sequences, and sinusoidal sequences in MATLAB. It also discusses operations that can be performed on sequences like addition, shifting, multiplication and folding. It includes MATLAB code examples and tasks for generating various signal types and performing operations on discrete signals.

Uploaded by

AR Rehman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views4 pages

Discrete Time Signals and Signal Operations: DSP Lab#03

The document discusses discrete time signals and various operations that can be performed on discrete signals in MATLAB. It defines a discrete signal x(n) and explains that in MATLAB it requires two vectors, one for the sample values and one for the sample positions. It then provides examples of generating and plotting common signal types like unit sample sequences, unit step sequences, complex exponential sequences, and sinusoidal sequences in MATLAB. It also discusses operations that can be performed on sequences like addition, shifting, multiplication and folding. It includes MATLAB code examples and tasks for generating various signal types and performing operations on discrete signals.

Uploaded by

AR Rehman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Registration No: Section: Date: ______________

DSP Lab#03

Discrete Time Signals and Signal Operations

A discrete signal is denoted by x(n), in which the variable n is integer valued and represents
discrete instances in time. For Matlab representation of signal x(n) we require two vectors, one
for sample values and the other for sample positions.

E.g. x (n) = {2, 1, -1, 0, 1, 4, 3, 7}

>> n=[-3,-2,-1,0,1,2,3,4]; x=[2,1,-1,0,1,4,3,7];

3.1 Unit Sample Sequence

To generate over the interval n1≤n0≤n2, we will use the following MATLAB function

Function [x, n] = impseq (n0, n1, n2)


n = n1:n2; x = [(n-n0) == 0];

Task(1): Write code to generate and plot the following sequence over interval -5≤n≤5

3.1.2 Unit step sequence:

To generate over the interval n1≤n0≤n2, we will use the following MATLAB function

function [x,n] = stepseq(n0,n1,n2)

n = n1:n2; x = [(n-n0) >= 0];


Registration No: Section: Date: ______________

Task(2): Write code to generate and plot the following sequence over interval 0≤n≤20

3.1.3Complex-valued exponential sequence

Task(3): Run the following code and note down the output. Also use real, imag and abs
functions to plot real part, imaginary part and magnitude.

>> n = [0:5]; x = exp ((2+3j)*n);

3.1.4 Sinusoidal Sequence


Task(4): Execute the following code and correctly answer the following questions

Fs = 100; % Sampling frequency


Freq = 10; % Frequency of the signal
time = 0:1/Fs:(3/Freq); % Time vector
A = 4; % Amplitude of the signal
signal = A * sin(2*pi*Freq*time); % Signal it self
stem(time,signal)

Number of samples in the signal: _____________________


Registration No: Section: Date: ______________

Number of cycles in the plotted signal: ______________


Number of samples in one cycle: ______________________
Time period of signal: _______________________________
Frequency of the signal: _____________________________

Task(5): Explain the following Matlab functions

square, sawtooth, chirp

3.2 Operation on Sequences:

3.2.1 Signal Addition:


If sequences are of unequal lengths, or if the sample positions are different for equal-length
sequences, then we cannot directly use the operator +. We have to first augment x1 (n) and x2
(n) so that they have the same position vector n.

Following function sigadd is used to accomplish this:

function [y,n] = sigadd(x1,n1,x2,n2)

n = min(min(n1) ,min(n2)) :max(max(n1) ,max(n2)) ;

y1 = zeros (1,length(n)); y2=y1;

y1 (find((n>=min(n1))&(n<=max(n1))==1))=x1;

y2 (find((n>=min(n2))&(n<=max(n2))==1))=x2;

y = y1+y2;

Note: Signal Multiplication can be carried out in the similar way.


Registration No: Section: Date: ______________

3.2.3 Signal Shifting:


This operation has no effect on x but vector n is changed by adding shifted amount to each
element.

function [y,n] = sigshift(x,m,n0)

n = m+n0; y=x;

3.2.4 Signal Folding


This operation can be carried out by the following function

function [y,n] = sigfold(x,n)

y = fliplr(x); n = - fliplr(n);

Task(6): Let x(n) = {1,2,3,4,5,6,7,6,5,4,3,2,1}. Determine and plot the following sequence:

You might also like