Professional Documents
Culture Documents
In-Lab Post-Lab
Lab #: O1
Lab Title: Introduction to Discrete Time Signal Processing on MATLAB
Submitted by:
Names Registration #
Rubrics to follow
In –Lab
Post- Lab
2 DSP LAB_1 REPORT
LAB#01:
Introduction to Discrete Time Signal Processing on MATLAB
Objective:
To understand the basic concept of the discrete-time signals and their representation on
MATLAB.
To demonstrates some basic MATLAB codes in order to achieve hands-on it.
LAB TASKS
INLAB TASK_1: Generate a Continuous time cosine signal and plot it.
CODE:
clc
clear all
t=-1:0.1:5;
x=cos(t);
plot(t,x,'linewidth',2)
3 DSP LAB_1 REPORT
INLAB TASK_2: Generate a Discrete time exponential signal and plot it.
CODE:
clc
clear all
x=0:0.1:2;
y=exp(-x);
stem(x,y,'fill','linewidth',2)
INLAB TASK3:
Write a MATLAB program for the ‘running average’, a running total is a sequence of partial
sum of a given sequence/signal. For example, the running totals of the signal {a, b, c, …}are a,
a+b, a+b+c, ... Use that program to find the running total of the discrete time signal of length
N=100. Write your program so that it is flexible. That is, you should be able to invoke your
program from the command window as follows:
>> y=running_averagel(x)
where x is the input signal, and y is the running total of that signal.
Editor file:
x=input('x=');
y=running_avg(x)
Function:
function [y] = running_avg(x)
sum=0;
for i=1:100;
sum=sum+x(i);
y(i)=sum;
end
4 DSP LAB_1 REPORT
Output:
5 DSP LAB_1 REPORT
where ‘m’ is the mean value of the signal x. For signal x, use all the integers from 1 to 1000.
CODE:
clc
clear all
a=1:1000;
m=mean(a);
L=length(a);
for i=1:L
b=a(i)-m;
end
s=sum(b)
var=s/L
L = length(x);
for i = 1: L
if x (i) < 0
x (i) = -1;
end
Code:
clc
clear all
N=10;
X=0;
for i=1:10
Y=[zeros(1,N+i) 1 zeros(1,N-i)]
X=X+Y;
end
stem(X, 'linewidth', 2)
Conclusion:
In this lab we conclude that we learned about to plot the different types of graph. After
performing this lab, we are familiar to the plotting and sub plotting of continuous and discrete
time graph.