0% found this document useful (0 votes)
19 views9 pages

Lab Report 03 Sas

This lab report describes creating MATLAB functions to generate and plot various signal sequences, including unit impulse, unit step, ramp, and signum sequences. The functions take parameters for the start and end points of the x-axis and generate the appropriate sequence value for each point. The functions then plot the sequence. Additional tasks calculate the energy and power of specific signals and create a function to plot unit impulse and step signals for both continuous and discrete time domains.

Uploaded by

Ghayyas Hassan
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)
19 views9 pages

Lab Report 03 Sas

This lab report describes creating MATLAB functions to generate and plot various signal sequences, including unit impulse, unit step, ramp, and signum sequences. The functions take parameters for the start and end points of the x-axis and generate the appropriate sequence value for each point. The functions then plot the sequence. Additional tasks calculate the energy and power of specific signals and create a function to plot unit impulse and step signals for both continuous and discrete time domains.

Uploaded by

Ghayyas Hassan
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/ 9

LAB REPORT 03

Lab 03- Study of Signal characteristics using


MATLAB

Task 01: Create a function “impseq”, which performs following operations:


Function [x,n]=impseq(n0,n1,n2)
 Takes three parameters (n0, n1, n2) as input, where ‘n1’ and ‘n2’ are lower and
upper limits of n-axis, and ‘n0’ is the delay.
 Generates a unit-impulse sequence using above mentioned three parameters.
 There should be two output arguments [x, n] of function ‘impseq’, where ‘x’ is
impulse sequence and ‘n’ is its corresponding n-axis.
 Finally, plot unit impulse ‘x’ against vector ‘n’.
 On the main window, type “[x,n]=impseq(0,-5,5)”

function [x n]=impseq(n0,n1,n2)
n0=0;
n =n1:n2;
x(n==n0)=1;
x(n~=n0)=0;
stem(n,x)
end

FUNCTION CALL
clc
clear all
close all
n0=0;
n1=-5;
n2=5;
impseq(n0,n1,n2);
Task 02: Make a function to form “stepseq” function which will output unit-step
sequence.
Function [x,n]=stepseq(n0,n1,n2)
 Unit Step Sequence
 We can have another elegant way to produce a step function
 Alternatively, we can use the “ones” function
 Type “stepseq[x,n]=(0,-5,5)” we get:

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

n0=0;
n=n1:n2;
x(n>=n0)=1;
x(n<=n0)=0;
stem(n,x)
end
FUNCTION CALL
clc
clear all
close all
n0=0;
n1=-5;
n2=5;
stepseq(n0,n1,n2);

Task 03: Create a function “rampseq”, which performs following operations:


Function [x,n]=rampseq(n0,n1,n2)
 Takes three parameters (n0, n1, n2) as input, where ‘n1’ and ‘n2’ are lower and
upper limits of n-axis, and ‘n0’ is the delay.
 Generates a ramp sequence using above mentioned three parameters.
 There should be two output arguments [x, n] of function ‘rampseq’, where ‘x’ is
impulse sequence and ‘n’ is its corresponding n-axis.
 Finally, plot ramp impulse ‘x’ against vector ‘n’.
function [x,n]=rampseq(n0,n1,n2)
n0=0;
n=n1:n2;
x=n;
x(n<0)=0;
stem(n,x)
end

FUNCTION CALL
clc
clear all
close all
n0=0;
n1=-5;
n2=5;
rampseq(n0,n1,n2);
Task 04: Create a function “sigseq”, which performs following operations:
Function [x,n]=sigpseq(n0,n1,n2)
 Takes three parameters (n0, n1, n2) as input, where ‘n1’ and ‘n2’ are lower and
upper limits of n-axis, and ‘n0’ is the delay.
 Generates a signum sequence using above mentioned three parameters.
 There should be two output arguments [x, n] of function ‘sigseq’, where ‘x’ is
impulse sequence and ‘n’ is its corresponding n-axis.
 Finally, plot signum sequence ‘x’ against vector ‘n’.

function [x,n]=sigseq(n0,n1,n2)
n0=0;
n=n1:n2;

x(n>=0)=1;
x(n<=0)=-1;
stem(n,x)
end
FUNCTION CALL
clc
clear all
close all
n0=0;
n1=-5;
n2=5;
sigseq(n0,n1,n2);

Task 05: Find E ∞ for the following signal

{
tri ( t )= 1−|t ||t |<1
0|t|≥ 1

clc
clear all
close all

t=-1:0.001:1
x=1-abs(t)

trapz(t,abs(x.^2))

ans =

0.6667

Task 06: Find P ∞ for the following signal

π
x [ n ] =cos ⁡( n)
4

clc
clear all
close all

n=1:1:10;
x=cos(pi./4.*n)

p=sum(abs(x.^2))./10

p=

0.4500

Task 07: Write a function which plot or stem a unit impulse and unit step signals. The
function takes values for starting and ending value of independent variable, i.e. t and n, and a
character for identification of discrete and continuous signal. Finally t plot or stem the
function or signal. e.g;
function f_name ( arg1 (start) , arg2 (end) , arg3 (D/C) )
function [x,t,n] = task7(n1,n2,t1,t2,ch)
if ch == 'c'

t = t1:t2;

x(t<0) = 0;
x(t>=0)=1;
subplot(2,1,1)
plot(t,x)
title('Unit Step')
x(t==0) = 1;
x(t~=0)=0;
subplot(2,1,2)
plot(t,x)
title('Unit Impulse')

elseif ch == 'd'
n = n1:n2;

x(n<0) = 0;
x(n>=0)=1;
subplot(2,1,1)
stem(n,x)
title('Unit Step')
x(n==0) = 1;
x(n~=0)=0;
subplot(2,1,2)
stem(n,x)
title('Unit Impulse')
end
end

FUNCTION CALL

clc
clear all
close all

task7(-1,10,-5,10,'c')
CRITICAL ANALYSIS

In this lab we have learned about

You might also like