You are on page 1of 7

1 DSP LAB_1 REPORT

Rubrics name & number Marks

In-Lab Post-Lab

Engineering R2: Use of Engineering Knowledge and follow Experiment Procedures:


Knowledge Ability to follow experimental procedures, control variables, and record
procedural steps on lab report.
R3: Interpretation of Subject Knowledge: Ability to interpret and explain
mathematical and/or visual forms, including equations, diagrams, graphics,
figures and tables.
Problem R5: Data/Evidence Measurements:
Analysis Ability to record raw data / evidence.
R6: Experimental Data Analysis:
Ability to interpret findings, compare them to values in the literature, identify
weaknesses and limitations.
Design R7: Implementing Design Strategy: Ability to execute a solution
taking into consideration design requirements and pertinent
contextual elements. [Block Diagram/Flow chart/Circuit Diagram]

R8: Best Coding Standards:


Ability to follow the coding standards and programming practices.
Modern R9: Understand Tools: Ability to describe and explain the principles behind
Tools Usage and applicability of engineering tools.
R11: Tools Evaluation:
Ability to simulate the experiment and then using hardware tools to verify the
results.
Individual R12: Individual Work Contributions: Ability to carry out individual
and responsibilities.
Teamwork
R13: Management of Team Work:
Ability to appreciate, understand and work with multidisciplinary team
members.

Lab Rubrics DSP Lab

Lab #: O1
Lab Title: Introduction to Discrete Time Signal Processing on MATLAB

Submitted by:
Names Registration #

Zia Ullah Fa20-bee-002


Muhammad safi Ullah Fa20-bee-029

Rubrics to follow

Rubrics # R2 R3 R5 R6 R7 R8 R9 R11 R12 R13

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

Post lab Task1:


Write a program to compute the variance and mean of a signal x. The variance σ is defined to
be:

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

Post lab Task2:


Can you explain what the following program does:

L = length(x);

for i = 1: L

if x (i) < 0

x (i) = -1;

end

X is not define and the code will gives error. If x is define


then this program finds the length of matrix x. Then replace
all the value by -1 whose less than 0 or negative. This
program compares the value by using for loop.
6 DSP LAB_1 REPORT

Post lab Task3:


Generate a step sequence u [n] as described in In-Lab section, use it to generate an impulse as
δ [n] = u[n] – u[n-1].
Code:
clc
clear all
n=-3:7;
k=zeros(1,length(n));
i=find(n==0)
k(i:end)=1;
subplot(3,1,1)
stem(n,k,'fill','linewidth',2)
n0=1;
z=zeros(1,length(n))
z(i+n0:end)=1;
subplot(3,1,2)
stem(n,z,'fill','linewidth',2)
subplot(3,1,3)
unit_step=k-z
stem(n,unit_step,'fill','linewidth',2)
7 DSP LAB_1 REPORT

Post lab Task4:


Generate an impulse sequence δ [n] as described in In-Lab
generate a step sequence section, use it to

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.

You might also like