0% found this document useful (0 votes)
229 views

Lab # 1 Plotting of Basic Signals

This document discusses discrete and continuous time signals including: 1. Unit impulse, unit step, and delayed versions of each in both discrete and continuous time. MATLAB implementations are provided using functions. 2. Periodic signals are introduced and the fundamental period is defined. A MATLAB example plots a periodic sine signal. 3. Harmonics are defined as integral multiples of a signal. Even and odd harmonics are discussed along with their roles in signal construction.

Uploaded by

Aasim07
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
229 views

Lab # 1 Plotting of Basic Signals

This document discusses discrete and continuous time signals including: 1. Unit impulse, unit step, and delayed versions of each in both discrete and continuous time. MATLAB implementations are provided using functions. 2. Periodic signals are introduced and the fundamental period is defined. A MATLAB example plots a periodic sine signal. 3. Harmonics are defined as integral multiples of a signal. Even and odd harmonics are discussed along with their roles in signal construction.

Uploaded by

Aasim07
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

LAB # 1

PLOTTING OF BASIC SIGNALS


DISCRETE SIGNALS:
Discrete time signals are defined only at discrete times, consequently for these
signal, the independent variable (usually time) takes on only a discrete set of values e.g.
stock market index.

UNIT IMPULSE:
One of the simplest discrete time signals is the unit impulse or unit sample,
which is defined as

0 n≠0
δ[n] 

1 n=1

0 n 

A delayed impulse by ‘no’ units can be defined as


0 n ≠ no
δ[n − no] 

1 n=no

no n
Any discrete time signal can be broken down into a series of individual impulses
which when added together give back the original discrete time signal.

y[ n]  2δ[n] 5δ [ n −3] 2δ[n 1] 7δ[n  2]


722 5

-2 -1 0 3

MATLAB IMPLEMENTATION:

1
Example 1:
Write and save the following function in matlab.

Function [x, n] =duifunct (L, no)


n= -L: L;
x=zeros (1, length (n));
x (L+no+1) =1;
Now call the function in matlab command window by using the following
command.
> [x,n]=duifunct(10,1);
> stem(n,x)
Give your comments on above example.
…………………………………………………………………………………………
…………………………………………………………………………………………
…………

Example 2:
Now call the above function with the value of L=5 & no=2; You will see
the following result.
1

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0
-5 -4 -3 -2 -1 0 1 2 3 4 5

Here L + no + 1 = 5 + 2 + 1 = 8 & so at 8 index we place 1 , all other indexes


have value of ‘0’.
Since we are defining from “– L: L” so the total length of this vector will be 2L +
1 . Given below is another way of creating unit impulse.
(2L  1) −(L  no) −1  L −no;
x  [ zeros(1,(L no)) 1 zeros(1,(L-no))];

-3 -2 -1 0 1 2 3

2
So we can implement the above function by another method.
Function [x, n] =dui2funct (L, no)
n= -L: L;
x=[zeros(1, (L+no)) 1 zeros(1,(L-no))];
Now call the given function another time by the same values as you have used before
for L& no and write down the results below.
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
………………
UNIT STEP:
The following relation gives a discrete unit step function.

1 n>=0
U[n-no] =

0 n<0

0 1 2 3 4 5
The following relation gives the general form of a delayed unit step
function
1 n>=no
U [n-no] =

0 n< no

no

MATLAB IMPLITATION:
Example # 3:
Function [x,n]=dusfunct(L,no)
n= -L:L;
len=length(n);
x=zeros(1,len);
x(L+no+1:len)=1;

Example#4:
Function [x,n]=dusfunct(L,no)
n= -L:L;
len=length(n);
x=[zeros(1,l+no) 1 ones(1,L-no)]

3
% x=[zeros(1,l+no) ones(1,L-no+1)]

Example 4 & example 5 are basically the some implementation ( I.e. they perform the
same task of creating a discrete unit step function) CONTINUOUS SIGNALS: In the case of
continuous signals the independent variable is continuous, and thus their signals are defined
for a continuum of values of time e.g. a speech signal that has values defined for all time.

UNIT IMPULSE in Continuous unit impulse is defined as


1 t=0
δ (t ) 

0 o.w

-3 -2 -1 0 1 2 3  Shifted impulse
definition is given by.
1 t-to
δ (t −to) 

0 Ow

-3 -2 -1 0 1 2 3 
here no=3;

MATLAB IMPLITATION:
Example #5:
Function [x,t]=cuifunct(L,no,inc)
t= -L:inc:L;
x=zeros(1,length(t));
x((L+no)/inc+1)=1;

Example #6:
Function [x,t]=cuifunct(L,no,inc)
t= -L:inc:L;
x=[zeros(1, L+no)/inc) 1 zeros(1, (L-no)/inc)];
Example 5 & 6 perform some task but in a deferent way of MATLAB
implementation.

4
UNIT STEP in Continuous time unit step function is defined in a manner similar to it s
discrete time counterpart i.e.
1 t>=0
u (t) 
0 t<0
The delayed singles general form will be
t>=to
u (t − to ) 
0< t0

MATLAB IMPLIMENTATION:
Example #7
Function [x,t]=cusfunct(L,no,inc)
t=-L:inc:L;
Len=length(t); x=zeros(1,len);
x(((L+no)/inc+1:len)=1;

Example #8
Function[x,t]=cusfunct(L,no,inc)
t=-L:inc:L;
x=[zeros(1,(L+no)/inc) 1 ones(1,(L-no)/inc)];

EVEN & ODD SINGALS:


Another set of useful properties of signals relates to their symmetry under time
reversals. A signal x (t) or x [n] is referred to as even signal if it is identical to its time
reversal component, i.e. with its reflection about the origin.

A signal is even if x(-t)=x(t) or


x[-n]=x[n]
A signal is considered odd if x(-t)= -x(t)
or
x[-n]= -x[n]
An important fact is that any signal can be broken into a sum of two signals, one of
which is even and one of which is odd.
The even part of a signal can be expressed
Xe (t)  1/ 2[x(t)  x(−t)]
The odd part representation of a signal I, given by
Xo (t)  1/ 2[x(t) − x(−t)]

5
EXERCISE:
E.1. Implement the function y[n] given by the relation
y[n]  2δ[n 3] [ n −1] 5δ[n] 6δ[n 5] −7δ[ n −2]
take L=6
E.2. Implement the continuous time function y(t) y(t)=3u(t)
+t*u(t)-(t-1)*u(t)-5u(t-2)

E.3. Shown below is the graph for discrete function Use “for” loop to implement the below
graph. You can use function of “example 1 or Example 2”.

Take L=40. Also plot the given graph


40

30

20

10

-10

-20

-30

-40
-40 -30 -20 -10 0 10 20 30 40

E.4. Implement the function shown in the graph below Take L=6

1.8

1.6

1.4

1.2

0.8

0.6

0.4

0.2

6
PERIODICITY & HARMONICS
A very common class of signals that we encounter is the class of periodic signals. A
periodic continuous time signal has the property that there is a positive value of ‘t’ for which
X(t) = x(t + aT)  A (continuous time)

Where a = 0,1,2,3,4 -----------


For all values of ‘t’. In other words a periodic signal has the property that it is
unchanged by a time shift of ‘T’. In this case we say that x(t) is periodic signal is the sine
signal.
X(t) = sin (wt)

Where w = 2πf; therefore

X(t) = sin (2πft)

Since sin(Q) = sin(Q + 2π) therefore the signal is periodic with the period ‘2π’.
A periodic signal in discrete time is defined similarly to continuous time periodic
signal. Specifically a discrete time periodic signal.
Specifically a discrete time signal x[n] is periodic with period ‘N’ where ‘N’ is
positive integer, i:e if it is unchanged by a time shift of ‘N’ i:e.
X[n] = x[n + bN]  B (discrete time)
Where b = 0,1,2,3,4,-----------

FUNDAMENTAL PERIOD
The fundamental period is the smallest positive value of ‘T’(continuous) or ‘N’
(discrete) for which the equations of periodicity held. Consider the example of a sine
function. In that case the signal is periodic on 2π, 4π, 6π and so on but the fundamental
time period of the signal is 2π.

MATLAB EXPLANATION OF PERIODIC SIGNALS

Example # 1
t=0:0.01:6; f=0.5;
x=sin(2*pi*f*t);
plot(t,x);

7
HARMONICS:
Harmonics are integral multiples of a signal. Consider the signal cos (wot). its
harmonics are cos(2 wot), cos (3 wot)is the fundamental harmonic.

EVEN, ODD HARMONICS:


If the harmonic of a signal function has an even co – efficient it is called an even
harmonic. Otherwise if the co – efficient is odd it is called an odd harmonic.

X(t) = Cos (wot)


Cos (2 wot), Cos (4 wot) , Cos (6 wot) …………………….. Even Harmonics Cos (3
wot), Cos (5 wot) , Cos (7 wot) …………………….. Odd Harmonics
Eve, odd harmonic play an important role in signal construction. Different waveforms
can be obtained by adding one type of harmonic e.g adding infinite odd harmonics of
sine/cosine where generates a square wave. Both will have a 90 phase shift from each other.
Practically it is not possible to add all the (infinite) number of harmonics to obtain a
perfect square wave but as the number of harmonics is increased from 10 onwards we obtain
a decent square wave.

Example # 2
inc  0.01;
t  0 : inc : 4;
f  0.25;
w  2 * pi * f ;
fundamental=sin(w*t);
harmaonic2=sin(2*w*t);
harmaonic3=sin(3*w*t);
harmaonic4=sin(4*w*t);
hold on;
plot(t,fundamental,'ro');
plot(t,harmonic2,'k--');
plot(t,harmonic3,'m:');
plot(t,harmonic4,'y');
hold off

SQUARE WAVE GENERATION BY COS FUNCTIONS:

8
For square wave generation by ‘cos’ functions odd harmonics we
use.
X(t)=4/π; (Cos (wt) – 1/3 Cos (3 wt) + 1/5 Cos (5 wt)+…….

Example#3
t  0 : 0.01: 6
f  0.5
w  2* pi * f
% plot function x(t)

EXERCISE:

E.1. Write MATLAB function for plotting the 5 harmonics of a signal x(t)=cos(wt) with
a fundamental frequency of f = 0.5 Hz. Take t = 0:0.01:2

E.2. What are the frequencies and Time periods at the all 5 harmonics in questions E.1.

E.3. If the frequency of x(t) = sin(2πft) is f = o.2hz what will be the time period of the 4rth
harmonic of the above signal x(t). plot x(t) and its 4rth harmonic and check the time period of
4rth harmonic in MATLAB. Do result agree with your theoretical calculation of time period
of 4rth harmonic?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy