0% found this document useful (0 votes)
51 views19 pages

Lab Report 1

The document outlines the award list and lab tasks for the Digital Signal Processing course (ELE-421L) at Abbottabad for Spring 2024, focusing on plotting basic signals and manipulating them using MATLAB. It includes detailed instructions, objectives, and MATLAB code examples for various tasks, along with evaluation rubrics for students' performance. The document is signed by the course instructor, Engr. Afshan Ishaq.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views19 pages

Lab Report 1

The document outlines the award list and lab tasks for the Digital Signal Processing course (ELE-421L) at Abbottabad for Spring 2024, focusing on plotting basic signals and manipulating them using MATLAB. It includes detailed instructions, objectives, and MATLAB code examples for various tasks, along with evaluation rubrics for students' performance. The document is signed by the course instructor, Engr. Afshan Ishaq.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Digital Signal Processing Electronic Department Abbottabad Spring -2024

Digital Signal Processing (ELE-421L)


Award List
Lab 1: Plot the Basic Signals and manipulate them using different commands
in Matlab

Student Name Huma Tariq


Registration No. 22abelt0928
CLOs Obtained Marks Remarks
CLO-1
CLO-2
CLO-3

Lab Rubrics
10-9 8-7 6-5 4-0

CLOs Excellent Good Satisfactory Needs


Improvement

CLO-1 Perfect Perfect simulation simulation with Simulation with


simulation with with minimal minimal concept, lack of concept,
Modern tool usage clear concept concept with minor errors with major errors

CLO-2 Answered all Answered Answered few Answered no


questions maximum questions questions correctly questions, absent,
problem Analysis correctly correctly answer all questions
incorrectly

CLO-3 Perfect report Format not Format not followed Format not followed
and completed followed. with some sections with major
Communication through all sections and completed all missing sections/conclusion
Report and viva sections missing

Signed By
Engr. Afshan Ishaq (Course Instructor)

1
Digital Signal Processing Electronic Department Abbottabad Spring -2024

Table of Contents
1.1 Objective...............................................................................................................................................4
1.2 USES.................................................................................................................................................4
1.3 Instructions............................................................................................................................................4
1.4 TASK 01..................................................................................................................................................4
1.4.1 Given Code.....................................................................................................................................5
1.4.2 Updated Code for Removed Glitches.............................................................................................5
1.4.4 Output Waveform...........................................................................................................................6
1.5 TASK 2....................................................................................................................................................6
1.5.1 Given Code.....................................................................................................................................6
1.6 TASK 3 (Part 1).......................................................................................................................................7
1.7 TASK 3 (Part 2).......................................................................................................................................8
1.7.1 Matlab Code...................................................................................................................................8
1.7.2 Output Waveform...........................................................................................................................8
1.8 Task 1.....................................................................................................................................................9
1.8.1 Matlab Code.......................................................................................................................................9
1.9 Task 2 (Part I).........................................................................................................................................9
1.9.1 Matlab Code.................................................................................................................................10
1.9.2 Output Waveform.........................................................................................................................11
1.10 Task 2 (Part II)....................................................................................................................................11
1.10.1 Matlab Code...............................................................................................................................11
1.10.2 Output Waveform.......................................................................................................................12
1.11 Task 4.................................................................................................................................................12
1.11.1 Matlab Code...............................................................................................................................12
1.11.2 Output Waveform.......................................................................................................................13
1.12 Task 1 (Part 1 : Unit Step Sequence)..................................................................................................13
1.12.1 Matlab Code...............................................................................................................................13
1.12.2 Output Waveform.......................................................................................................................14
1.13 TASK 1 (PART 2: Sine Signal)..............................................................................................................14
1.13.1 Matlab Code...............................................................................................................................14
1.13.2 Output Waveform.......................................................................................................................15
1.14 TASK 1 (Part 3 : Unit Step Signal).......................................................................................................15
1.14.1 Matlab Code..........................................................................................................................15

2
Digital Signal Processing Electronic Department Abbottabad Spring -2024
1.14.2 Output Waveform.......................................................................................................................16
1.15 TASK 1 (PART 5 : Cosine Wave)..........................................................................................................16
1.15.1 Matlab Code...............................................................................................................................16
1.15.2 Output Waveform.......................................................................................................................17
1.16 TASK 1 (PART 5: Unit Ramp Function)................................................................................................17
1.16.1 Matlab Code...................................................................................................................................17
1.16.2 Output Waveform.......................................................................................................................18
1.17 TASK 1 (PART 6: Exponential signal)..................................................................................................18
1.17.1 Matlab Code...............................................................................................................................18
1.17.2 Output Waveform.......................................................................................................................19

3
Digital Signal Processing Electronic Department Abbottabad Spring -2024
LAB NO. 1
PLOT THE BASIC SIGNALS AND MANIPULATE THEM USING
DIFFERENT COMMANDS IN MATLAB

1.1 Objective
The objective of this lab is to plot the some commonly used sequences using graphic editor of
Matlab and also find some parameters of signals using Matlab commands like sum, max, min,
find etc.
PRE LAB
1. What is eps in Matlab?

EPS COMMAND IN MATLAB


 EPS in MATLAB represents floating-point relative accuracy.
 It defines the smallest possible difference between two distinct numbers.
 EPS helps determine numerical precision in calculations.
 It ensures accuracy when working with floating-point operations.

1.2 USES

 It is commonly used in numerical algorithms to determine when two numbers are


sufficiently close to each other.
 In numerical analysis eps helps in error analysis and understanding the effects of round
off errors in computation.
In Lab

1.3 Instructions
You have to
 plot the tutorial m-files, Label them properly (x-axis-axis,Title,legends)
 every graph title (‘whatever is plotted (class no)
 Comment your M-files
 Conclusion(suggestion) must be possibly on the graph

1.4 TASK 01
Q1. Following is an m-file to generate a signal and its samples, Remove the glitches so that the
graph is smooth.

1.4.1 Given Code

A=5;

4
Digital Signal Processing Electronic Department Abbottabad Spring -2024
F0=2;
T0=1/F0;
theta= pi/4;
Fsam=10;
Tsam=1/Fsam;
dur=5*T0;
t=0:Tsam:dur;
x=A*cos(2*pi*F0*t+theta);
figure(1)
plot(t,x);
hold on
stem(t,x)
title('continous time siganl for 15 msec')
xlabel('time in msec')
ylabel('freq in Hertz’)

1.4.2 Updated Code for Removed Glitches

%%Huma Tariq
A=5;
F0=0.6;
T0=1/F0;
theta= pi/4;
A=5;
F0=0.5;
T0=1/F0;
theta= pi/4;
Fsam=10;
Tsam=1/Fsam;
dur=5*T0;
t=0:Tsam:dur;
x=A*cos(2*pi*F0*t+theta);
plot(t,x);
hold on
stem(t,x)
title('Continous Time Siganl For 15 msec (Huma Tariq,Class No 2)')
xlabel('Time in milli sec')
ylabel('Freq in Hertz')

1.4.3 Discussion

5
Digital Signal Processing Electronic Department Abbottabad Spring -2024
This MATLAB code generates a cosine signal with an amplitude of 5, frequency of 2 Hz, and a
phase shift of π/4. It samples the signal at 10 Hz for 5 periods and plots both the continuous and
sampled signals together for comparison.

1.4.4 Output Waveform

Figure 1: Continuous-Time Signal Waveform for 15 ms

1.5 TASK 2
Q1. Find command

1.5.1 Given Code

x=[-4:4]

x= -4 -3 -2 -1 0 1 2 3 4

>> find(x==1) %it would work for integers only%

ans = 6

>>x(ans)

6
Digital Signal Processing Electronic Department Abbottabad Spring -2024
=1

>>theta=[-pi:pi/1024:pi]

Q1. Find the value of x1 at pi/3 & pi/4. Hint:eps

1.6 TASK 3 (Part 1)


Q1. Plot the following sequence by following the commands
1. x1(n) =0.5δ(n-4) for -5≤n≤5

1.6.1 Matlab Code


%%Huma Tariq

n=[-5:5];

x1=zeros(size(n));

ind1=find(n==4);

x1(ind1)=0.5;

stem(n,x1,'fill');

xlabel('Time (sec)');

ylabel('Amplitude of the signal');

title(' Impulse Response at n-4 (Huma Tariq,Class No 2)')

axis([-5,5,0,1]);

1.6.2 Output Waveform

Figure 2: Plot

1.7 TASK 3 (Part 2)


x2(n) =4.5δ(n+7)+1.5 δ(n-1) for -10≤n≤2

7
Digital Signal Processing Electronic Department Abbottabad Spring -2024
1.7.1 Matlab Code

%%Huma Tariq
n=[-10:2];
x2=zeros(size(n));
ind1=find(n==-7);
ind2=find(n==1);
x2(ind1)=4.5;
x2(ind2)=1.5;
stem(n,x2,'fill');
xlabel('Time (sec)');
ylabel('Amplitude');
title('Impulse Response at -7 AND 1(Huma Tariq ,Class NO 2)')
axis([-10,2,0,5]);

1.7.2 Output Waveform

Figure 3: Waveform of Continuous time signal for 15msec

IN LAB TASKS
Q1. Plot the sequence based on unit step signal

1. x3(n) =0.5u(n-4) for 0≤n≤10

8
Digital Signal Processing Electronic Department Abbottabad Spring -2024
1.8 Task 1

1.8.1 Matlab Code


%%Huma Tariq
n=[0:10];
x1=zeros(size(n));
ind1=find(n>=4);
x1(ind1)=0.5;
stem(n,x1,'fill');
xlabel('Time (sec)');
ylabel('Amplitude');
title('Discrete Time Unit Step Signal (Huma Tariq ,ROLL NO=2)');
axis([0,10,0,1]);
1.8.2 Output Waveform

Figure 4: Waveform of the unit step signal for n>4

1.9 Task 2 (Part I)


x4(n) =u(n)-u(n-5) for 0≤n≤10

1.9.1 Matlab Code

%%Huma Tariq
n=[0:10];
x1=zeros(size(n));
ind1=find(n>=0);
ind2=find(n>=5);
u=x1;

9
Digital Signal Processing Electronic Department Abbottabad Spring -2024
v=x1;
u(ind1)=1;
v(ind2)=1;
x2=u-v;
subplot(3,1,1);
stem(n,u);
xlabel('Time(sec)')
ylabel('Amplitude')
title('Unit Step Signal (Huma Tariq,Roll no 2)')
axis([0,10,0,1])
subplot(3,1,2);
stem(n,v);
xlabel('Time(sec)')
ylabel('Amplitude')
title('Unit Step Signal at n=5 (Huma Tariq,Roll no 2)')
axis([0,10,0,1])
subplot(3,1,3);
stem(n,x2)
xlabel('Time(sec)')
ylabel('Amplitude')
title('Subtraction of Unit Step Signal (Huma Tariq,Roll no 2)')
axis([0,10,0,1])

10
Digital Signal Processing Electronic Department Abbottabad Spring -2024
1.9.2 Output Waveform

Figure 5: Subtraction of Unit Step Signal

1.10 Task 2 (Part II)


x5(n) =0.5u(-n+4)u(n)

1.10.1 Matlab Code

%Huma Tariq
n=[-10:10];
x1=zeros(size(n));
u=x1;
v=x1
ind1=find((-n+4)>=0);
ind2=find(n>=0);
u(ind1)=1;
v(ind2)=1;
subplot(3,1,1)
stem(n,v);
xlabel('Time(sec)');
ylabel('Amplitude');
title('Unit Step Signal (Huma Tariq,Class NO 2)')

11
Digital Signal Processing Electronic Department Abbottabad Spring -2024
x2=u.*v
subplot(3,1,2)
stem(n,u);
xlabel('Time(sec)')
ylabel('Amplitude')
title('Unit Step Signal of -n+4(Huma Tariq,Class NO 2)')
subplot(3,1,3)
stem(n,x2);
xlabel('Time(sec)');
ylabel('Amplitude');
title('Multiplication of Two Unit Step Signal (Huma Tariq,Class NO 2)')

1.10.2 Output Waveform

Figure 6: Multiplication of Signals

12
Digital Signal Processing Electronic Department Abbottabad Spring -2024
1.11 Task 4
x6(n) = x5(n-2)

1.11.1 Matlab Code

%%Huma Tariq
n=[0:10];
x=zeros(size(n));
u=x;
v=x;
ind1=find((-n+6)>=0);
ind2=find((n-2)>=0);
u(ind1)=1;
v(ind2)=1;
x1=0.5*v.*u;
stem(n,x1);
xlabel('Time(sec)');
ylabel('Amplitude');
title('Plot of 2<u(n)<6 (Huma Tariq ,Class NO 2)')

1.11.2 Output Waveform

Figure 7: Plot of 2 < u(n) < 6


Post Lab
Q1. Write a MATLAB program to generate the following elementary signals.

13
Digital Signal Processing Electronic Department Abbottabad Spring -2024
1.12 Task 1 (Part 1 : Unit Step Sequence)

1.12.1 Matlab Code

%%Huma Tariq
t=[0:0.01:10]
N=20;
Sequence = ones(1,N);
stem(Sequence);
xlabel('Samples');
ylabel('Amplitude');
title('Unit Step Sequence (Huma Tariq ,Class NO 2)');

1.12.2 Output Waveform

Figure 8: Waveform of the Unit Step Sequence

1.13 TASK 1 (PART 2: Sine Signal)

1.13.1 Matlab Code

%%Huma Tariq
t=[0:0.01:10]
Result=sin(2*pi*t);

14
Digital Signal Processing Electronic Department Abbottabad Spring -2024
plot(t,Result);
xlabel('Time(sec)');
ylabel('Amplitude');
title('Sine Wave (Huma Tariq,Class NO 2)');

1.13.2 Output Waveform

Figure9: Waveform of Sine Signal

1.14 TASK 1 (Part 3 : Unit Step Signal)

1.14.1 Matlab Code

%%Huma Tariq
n=[-50:50];
x1=zeros(size(n));
u=x1;
v=x1
ind1=find((-n+4)>=0);
ind2=find(n>=0);
u(ind1)=1;
v(ind2)=1;
stem(n,v);
xlabel('Time(sec)');
ylabel('Amplitude');

15
Digital Signal Processing Electronic Department Abbottabad Spring -2024
title('Unit Step Signal From -50 to +50 (Huma Tariq,Class NO 2)')

1.14.2 Output Waveform

Figure 0: Waveform of Unit Step Signal

1.15 TASK 1 (PART 5 : Cosine Wave)

1.15.1 Matlab Code

%%Huma Tariq
t=[0:0.01:10]
Result=cos(2*pi*t);
plot(t,Result);
xlabel('Time(seconds)');
ylabel('Amplitude');
title('Cosine Wave (Huma Tariq ,Class NO 2)');

16
Digital Signal Processing Electronic Department Abbottabad Spring -2024
1.15.2 Output Waveform

Figure 11: Cosine Waveform

1.16 TASK 1 (PART 5: Unit Ramp Function)

1.16.1 Matlab Code


%%Huma Tariq
t=[0:0.1:10]
N=20;
Unit_Ramp_Function = 0:(N-1);
stem(Unit_Ramp_Function);
xlabel('Samples');
ylabel('Am plitude');
title('Unit Ramp
Function (Huma
Tariq,Class NO 2)');

1.16.2 Output
Waveform

17
Digital Signal Processing Electronic Department Abbottabad Spring -2024

Figure 12: Waveform of Unit Ramp Function

1.17 TASK 1 (PART 6: Exponential signal)

1.17.1 Matlab Code

%%Huuma Tariq
t=[0:0.01:10]
A=5;
alpha = 0.5; %% Decay constant
Exponential_Signal = A* exp(alpha*t);
plot(t,Exponential_Signal);
xlabel('Samples');
ylabel('Amplitude');
title('Exponential Signal (Huma Tariq, Class NO 2)');

1.17.2 Output Waveform

18
Digital Signal Processing Electronic Department Abbottabad Spring -2024

Figure 3: Waveform of Exponential Signal

19

You might also like