You are on page 1of 30

Sample Viva Questions

1.
2.
3.
4.

Basic commands and their syntax.


Difference between the script and function file and their advantages.
Plotting and labelling the signals. Commands used in plotting and labelling.
Different methods of plotting i.e. figure, subplot, multiple plots in same figure.

Critical Analysis / Conclusion

Take Home Exercise


(Please attach extra A4 White page)
1.

Write a function that accepts as input argument a vector

( )=
Plot ( ) for x from

and two scalars m and s and plots the function \

=
=

2. Define and plot the signal ( ) = cos( )

3. Define and plot the real and the imaginary part of the signal
( )=
,

in the time of two periods.


4. Creates a function that plots the function
function in the interval [2 2 ]

( )=

)/

) and plot the

( ) through your

Performance

Viva

(10 Marks)

(5 Marks )

Total/15
Performance

/4

Results

/3

Critical Analysis

/1

Take Home Exercise

/2

Comments

Instructor Signature and Date:

|EEE-223 | Signals & Systems Lab Manual

27

Lab#2 Understanding the Basic Signals using MatLab


Objectives
To familiarize the students basic signals using MatLab. Following are the main features of the experiment.
Basic Continuous and Discrete time Signal
o Unit Impulse
o Unit Step
o Sinusoidal
o Complex Exponential

Equipment Required
Software: MATLAB
Hardware: Computer

Lab Instructions
This lab activity comprises of three parts: Pre-lab, Lab Exercises, and Post-Lab Viva session.
The students should perform and demonstrate each lab task separately for step-wise evaluation.
Only those tasks that are completed during the allocated lab time will be credited to the students.
Students are however encouraged to practice on their own in spare time for enhancing their skills.

Lab Report Instructions


All questions should be answered precisely to get maximum credit. Lab report must ensure following items:

Lab objectives
MATLAB codes
Results (graphs/tables) duly commented and discussed
Conclusion

Part I- Characterization of Signal by Variable Type


Continuous Time Signals
A signal is called continuous-time (or analog) signals if the independent (time) is defined in continuous interval.
For 1 signals, time domain of signal is continuous interval of the axis. In other words, for continuous-time
signals the independent variable is continuous. Moreover, the dependent value that usually denotes the
amplitude of the signal is also continuous variable. An example of such a signal is speech as a function of time.
An analog Signal is expressed by a function ( ), where takes real values.

Lab Task
Plot the continuous time signal

( ) = cos( )

Solution
% Program to understand the CT signal
% Muhammmad Usman Iqbal
% EEE223 Signals and Systems
clc

clear all
close all
t= -10:0.1:10
x= cos(t)
plot (t,x)

xlabel('Time Axis')
ylabel('Amplitude')
title('Graph of x(n)=cos(t)')

Roll Number :________________________


Plot and code according to your roll number.

Discrete Time Signals


A signal is called a discrete-time signal if the independent variable (time) is defined in a discrete interval (e.g.,
the set of integer number), while the dependent variable is defined in a continuous set of values. In the
following example, the discrete-time signal [ ] =
[ ] is plotted. Note that when referring to discrete time
the variable n is typically used to represent the time.
|EEE-223 | Signals & Systems Lab Manual

29

Lab Task
Plot the discrete time signal

[ ] = cos[ ]

Solution
% Program to understand the CT signal
% Muhammmad Usman Iqbal
% EEE223 Signals and Systems
clc
clear all
close all
n= -10:.1:10;
x= cos(n);
stem (n,x)

xlabel('Time Axis')
ylabel('Amplitude')
title('Graph of x(n)=cos(n)')

ROll Number:_________________________
Modify the code to plot using your roll number.

A discrete time signal x[n] is usually obtained by sampling a continuous-time signal ( ) at a constant rate.
Suppose Ts is the sampling period, that is every we sample the value of ( ). Suppose also that n , i.e.
= 0, 1, 2, 3, ..The sequence of the sample is derived from the continuous time signal ( ).
Lab Task
Modify the above lab tasks to plot the CT and DT signals together.
Solution

Digital Signals
Digital signals are the signals that both independent and dependent variables take values from a discrete set.
In the following example, the signal [ ] =
[ ] is again plotted, but we use the command round to limit
the set of values that [ ] can take, That is, [ ] can be 1,0 1.
Lab Task
Plot the digital signal [ ] = cos( ),

Solution
% Program to

understand the Digital signal

|EEE-223 | Signals & Systems Lab Manual

31

% Muhammmad Usman Iqbal


% EEE223 Signals and Systems
clc
clear all
close all
n= -10:.01:10;
x= cos(n);
x=round (x)
plot (n,x, 'Linewidth',3)
grid

xlabel('Time Axis')
ylabel('Amplitude')
title('Graph of x(n)=cos(n)- Digital Signal')

Part II - Basic Continuous Time Signals


We present the basic continuous Time Signals along with the way they are implemented and plotted
in MATLAB.
Sinusoidal Signal
The first basic category presented is that of sinusoidal signal. This type of signal is of the form
( )=

( + )

Where
=

/ ,

=
=

,
).

Sinusoidal signals are periodic signals with fundamental period


=2 /

given by

Finally, a useful quantity is the frequency f given in Hertz. Frequency


=
Lab Task
Plot the signal ( ) = 3 cos(3

is defined by

/2 .

+ /3) in four periods.

Solution
First, the period is calculated as T=2 /=2 /3 =2/3. Hence, the MATLAB implementation is as
follows.
% Program to understand the plotting of sinusoidal signal
% Muhammmad Usman Iqbal
% EEE223 Signals and Systems
clc
close all
clear all
A=3;
omega=3*pi;
thita=pi/3;
T= 2*pi/omega;
t=0:0.01:4*T;
x=A*cos(omega*t+thita);
plot(t,x)
title ('sinusoidal signal')
xlablel('time')
ylabel('Amplitude')

|EEE-223 | Signals & Systems Lab Manual

33

When referring to the sinusoidal signals we refer both to cosines and sine, as a cosine and sine are infact the
same signal with a

phase difference.

Lab Task
Plot the following two signals together in the same plot.
( ) = cos( )

( ) = sin( + )
2

Solution

Exponential Signals
Exponential signals are signals of the form
( )=
If

> 0 , ( ) is an increasing function while

if

< 0, ( ) is a decreasing function.

At = 0 the signal takes the value

(0) =
Lab Task
Plot the Signal ( ) =

int the time interval -T .

Where

=
And

( )=

= 1.

= /2

Solution
% Program to understand the plotting of exponential signal.
% Muhammmad Usman Iqbal
% EEE223 Signals and Systems
clc
close all
clear all
A= input ('Enter the Roll Number')
beta1= A/100
beta2= -A/100
T= A/2;
t=-T:.1:T;
x=A*exp(beta1*t);
y=A*exp(beta2*t);
plot(t,x,'or',t,y,'.b')
xlabel('time')
ylabel('Amlitude')
title ('Exponential Signal')
legend('Growing Exponentiaa','Decaying Exponential')

|EEE-223 | Signals & Systems Lab Manual

35

When referring to the sinusoidal signals we refer to the both sines and cosines, as cosine and a sine are in
fact the same signal with a

= , phase difference.

Complex Exponential Signals


Another signal highly associated with sinusoidal signal is the complex exponential signal.
periodic with fundamental period given by
=

is also

. According to derived straightforward from Eulers Formula

(cos( + ) + sin( + ))

Lab Task
Plot the real and imaginary parts of signal ( ) = 2

in the time of one period.

Solution
First of all find the period of the signal.
=

2
2
=
=2

% Program to understand the Complex Exponential Signal


% Muhammmad Usman Iqbal
% EEE223 Signals and Systems
clc
close all
clear all

t=0:.1:2;
y_re=real(2*exp(1i*pi*t+pi/3));
y_im=imag(2*exp(1i*pi*t+pi/3));
plot(t,y_re,t,y_im,'-.')
title('Complex Exponential')
xlabel('TIme')
ylabel('Apmmlitude')
legend ('Real Part','Imaginary Part')

Lab Task

Solution

Unit Step Function


Another basic signal is unit step function u(t). The unit step function is given by
u(t)=

1,
0,

>0
<0

The MATLAB command that generates the unit step function is the command heaviside(t).
According to MATLAB programmers, unit step function is given by
u(t)=

1,
0,

>0
<0

i.e. it is not defined at t=0, In the following example three different methods of defining and plotting the unit
step function are presented.
Lab Task
Implement the unit step function.
Solution
Method 1
% Program to understand the Unit Step Signal
% Muhammmad Usman Iqbal
% EEE223 Signals and Systems

|EEE-223 | Signals & Systems Lab Manual

37

clc
close all
clear all

% unit step signal


% method one
t=-5:0.1:10;
u=heaviside(t);
plot(t,u);
ylim([-0.3 1.3]);
title ('Unit Step Using heaviside(t)')
xlabel('TIme')
ylabel('Amplitude')
% method two
figure
t1=-5:.1:0
t2=0:.1:10
u1=zeros(size(t1))
u2=ones(size(t2));
t=[t1 t2];
u=[u1 u2];
plot(t,u);
ylim([-0.3 1.3])
title ('Unit Step using Zeros and Ones ')
xlabel('TIme')
ylabel('Amplitude')
% method three
figure
t=-5:.1:10;
u=[zeros(1,50) ones(1,101)];
plot(t,u);
ylim([-0.3 1.3])
title ('Unit Step using Zeros and Ones ')
xlabel('Time')
ylabel('Amplitude')

Write down your observation about using above methods.

The general form of the unit step function is


u(

)=

1,
0,

0
<0 <

Suppose that we want to define and plot the unit step function for
plot the function.
Lab Task
Plot the unit step function for

=2 i.e., we want to define and

= 2 using all methods discussed previously

Solution

|EEE-223 | Signals & Systems Lab Manual

39

Unit Impulse or Dirac Delta Function


The Dirac delta ( ), strictly speaking, is not a function but is defined through its properties. The
main property is

( ) ( ) = (0),

Where (. ) is an arbitrary function. Suppose that ( ) = 1, t (, ). Then

( ) = 1.

For special reasons, ( ) can be losely defined as a function that is infinite at t=0 and zero elsewhere.
This is the way that ( ) is implemented from the MATLAB programmers. The mathematical
expression is
( )=

,
0,

=0
0

An alternative definition for the Dirac function that is usually applicable when dealing with discretetime signal is given now. In this case, we refer to ( ) as the
or the
function. The
mathematical definition of delta function is
( )=

1,
0,

=0
0

Lab Task
Plot the unit impulse function.
Solution
% Program to understand the UnitImpulse
% Muhammmad Usman Iqbal
% EEE223 Signals and Systems
clc
close all

%Unit impulse function


%dirac(t)
t1=-5:.1:-0.1;
t2=0;
t3=0.1:.1:10;
d1=zeros(size(t1));
d2=1;
d3=zeros(size(t3));
t=[t1 t2 t3];
d=[d1 d2 d3];
plot(t,d)
title ('Unit Impulse Using dirac(t)')
xlabel('TIme')
ylabel('Amplitude')
%second way
figure
t=-5:.1:10;
s=gauspuls(t)
plot(t,s)
title ('Unit impulse Using gauspuls(t)')
xlabel('TIme')
ylabel('Amplitude')
%

third way

|EEE-223 | Signals & Systems Lab Manual

41

figure
t=-5:.1:10
d=[zeros(1,50) inf zeros(1,100) ];
plot(t,d)
title ('Unit Impulse Using zeros and inf(t)')
xlabel('TIme')
ylabel('Amplitude')

The general form of Dirac function is


(

)=

,
0,

Lab Task
Define and plot the Dirac function for

=-2 i.ie, we want to define and plot the function ( + 2).

Solution

|EEE-223 | Signals & Systems Lab Manual

43

Part III Basic Discrete Time Signals


Now we will discuss the discrete time signals. Discrete time signals are the sequences. A sequence [ ].
( ) consists of infinite (real or complex) elements or samples. DT signals are treated in the same way as
the continuous time signals. However there are two main differences.
1. The definition of the time. For the discrete time signals, time is defined by the step 1.
2. The graph of the discrete time signals is obtained by the stem command. Stem is similar to plot but is
suitable for discrete time signals.

Unit Impulse Sequence


The unit impulse sequence is the counter part of the dirac delta function when dealing with discrete time
signals. It is also known as Kronecker delta. The mathematical expression of the [ ] is :
[ ]=

1,
0,

=0
0

In general, the unit impulse sequence is given by,


[

]=

1,
0,

Lab Task
Plot the unit impulse sequence.
Solution
% Program to understand the Unit Impulse
% Muhammmad Usman Iqbal
% EEE223 Signals and Systems

Unit impulse sequence

clc
close all
clear all

%delta(t)
n=-3:3
d=gauspuls(n)
stem(n,d)
title('Unit Impulse Using gauspuls(n)')
xlabel('n')
ylabel('Amplitude')
ylim([-0.5 1.5])
% second way
figure
n1=-3:-1;
n2=0;
n3=1:3;
n=[n1 n2 n3]
d1=zeros(size(n1));
d2=1;
d3=zeros(size(n3));
d=[d1 d2 d3]
stem(n,d)
title('Unit Impulse-Second Method')
xlabel('n')
ylabel('Amplitude')
ylim([-0.5 1.5])

% third way
figure
n1=-3;
n2=3;
n=n1:n2
d=(n==0)
stem(n,d)
title('Unit Impulse - Third Method')
xlabel('n')
ylabel('Amplitude')
ylim([-0.5 1.5])

|EEE-223 | Signals & Systems Lab Manual

45

Unit Step Sequence


The unit step sequence is the counterpart of the unit step function when dealing with discrete time signals.
The mathematical expression is
[ ]=

1,
0,

0
<0

In general case, the unit step sequence is given by


[ ]=

1,
0,

<

The command of the Heaviside is not applicable to the unit step sequence.

Lab Task
i.
Plot the unit step sequence.
ii.
Plot the unit step sequence for

=2

Solution
% Program to understand the UnitImpulse
% Muhammmad Usman Iqbal
% EEE223 Signals and Systems
clc
close all
clear all
%

Unit step sequence

u[n]
n1=-3:-1;
n2=0:5;
n=[n1 n2];
u1=zeros(size(n1));
u2=ones(size(n2));
u=[u1 u2];
stem(n,u)
title ('Unit Step-first method ')
xlabel ('n')
ylabel ('Apmlitude')
ylim ([-0.5 1.5])

second way
figure
n=-3:5
n0=0;
u=(n>=n0)
stem(n,u)
title ('Unit Step-second method ')
xlabel ('n')
ylabel ('Apmlitude')
ylim ([-0.5 1.5])

%u[n-n0]
figure
n1=-3:1;
n2=2:5;
n=[n1 n2];
u1=zeros(size(n1));
u2=ones(size(n2));
u2=ones(size(n2));
u=[u1 u2];
stem(n,u)
title ('Unit Step-u[n-n0]-first method')
xlabel ('n')
ylabel ('Apmlitude')
ylim ([-0.5 1.5])

second way
figure
n=-3:5

|EEE-223 | Signals & Systems Lab Manual

47

n0=2;
u=((n-n0)>=0)
stem(n,u)
title ('Unit Step-u[n-n0]-second method')
xlabel ('n')
ylabel ('Apmlitude')
ylim ([-0.5 1.5])

Real Exponential Sequence


The mathematical expression of a real valued exponential sequence is [ ] =
is ascending if |a|>1, and descending if | | < 1.

Lab Task
Plot the ascending and descending real exponential sequence for the value of
range of
.

Solution

, the sequence [ ]

in the

|EEE-223 | Signals & Systems Lab Manual

49

Sinusoidal Sequence
The sinusoidal sequence is defined by the expression of the form
[ ]=

cos(

+ )

[ ]=

Where
=
=
=
Lab Task
Plot the sinusoidal sequence
[ ]=
Solution

cos 2

=
0

+ )

|EEE-223 | Signals & Systems Lab Manual

51

Sample Viva Questions


1. Questions regarding different elementary signals such as, Exponential signal, Ramp signal,
Unit impulse function, unit step function, etc.
2. Question regarding MATLAB build in commands e.g. heaviside, diff(), int(), linspace etc.
3. Question regarding signal plotting e.g. plot, stem, label, xlim, ylim, grid etc.
4. Conceptual questions from the theory/Lab point of view.

Critical Analysis / Conclusion

(By Student about Learning from the Lab)

Take Home Exercise


(Please attach extra A4 White page if needed)
1. Define and plot the signal ( ) = cos( ).
2. Define and plot the real and the imaginary part of the signal ( ) =
, in the time of two
periods.
3. Plot in the time interval 5 10, the following signals:
a. ( ) + 2 ( )
b. ( ) + 2 ( ) + 1
c. ( ) + ( )
d. [ ] + 1
[ ]+ [ ]+3
e.
( + 1) + 2 ( 1)
f.
g. ( + 1) + ( 1) + 1
h. [ 1] + 1
4. Rectangular Pulse Function: The rectangular pulse function ( ) is rectangular pulse with unit
amplitude and duration T. it is defined in terms of the unit step function ( ) as
( )=

Plot the rectangular pulse function for the

= 1,
0,

Performance

Viva

(10 Marks)

(5 Marks )

Total/15
Performance

/4

Results

/3

Critical Analysis

/1

Take Home Exercise

/2

Comments

Instructor Signature and Date:

|EEE-223 | Signals & Systems Lab Manual

53

Lab# 3: Properties of signals and their transformations


Objectives
This experiment is designed to familiarize the students with the basic properties of continuous and discrete
time signals. The main features of the experiment include:
Construction of periodic signals, casual signals, energy and power signals, even and odd signals,
deterministic and stochastic signals,
Operations on signals like time reversal or reflection time scaling and time shifting.

Equipment Required
Software: MATLAB
Hardware: Computer

Lab Instructions
This lab activity comprises of three parts: Pre-lab, Lab Exercises, and Post-Lab Viva session.
The students should perform and demonstrate each lab task separately for step-wise evaluation.
Only those tasks that are completed during the allocated lab time will be credited to the students.
Students are however encouraged to practice on their own in spare time for enhancing their skills.

Lab Report Instructions


All questions should be answered precisely to get maximum credit. Lab report must ensure following items:

Lab objectives
MATLAB codes
Results (graphs/tables) duly commented and discussed
Conclusion

Part I-Properties of Continuous Time Signals


Continuous Time Periodic Signals
A continuous-time signal x(t) is periodic if there is a positive number T such that
( )= ( + )
If T is the smallest positive value of T for which above equation is satisfied, then T is called the fundamental
period of the signal. Moreover, if k Z another expression that denotes the periodicity of a signal is
( ) = x( +
For example, a sinusoidal signal ( ) =
4 / ,

=6 / ,

),

+ ) is periodic with fundamental period

= 8 / , etc, are also periods of the signal x(t).

Lab Task
Verify that the signal ( ) =

( ) is periodic.

, but

Solution
=2

First, the Period of the signal is computed as

= 2 . Of course, it is not possible to verify the

periodicity for all integers k, i.e, to verify that ( ) = ( +


1 10 and time 1 5.

A sinusoidal sequence [ ] =
satisfied.

),

. The periodicity of ( ) is verified for

+ ) is not always periodic, i.e., condition of periodicity is not always

Sum of Continuous Time Periodic Signals


Suppose that 1( )
2( ) are periodic signals with periods 1
2, respectively. In this chapter, the
condition that must be fulfilled in order for the signal ( ) = 1( ) + 2( ) to be also periodic is given.
Moreover, the period of ( ) is computed. Since 1( )
2( ) are periodic, we get
( )=
Thus,

( +
( )=

),

( )+

( )=

and

( )=

( +

)+

( +

( +

),

),

Suppose that x(t) is indeed periodic with period T. Then, the following relationship holds:
( )= ( + )=

( + )+

( + ).

Combining the equations we yields,


( + )+

( + )=

( +

)+

( +

.)

Equation is valid if
=

if
are prime numbers, then the period of the signal ( ) =
according to relation defined in above equation.
Lab Task
Plot the signal ( ) =

( )+

( )+

( ) is computed directly

(3 ) in time of three periods.

Solution
The period 1 of

( ) is computed as 1 =

= 2 /3. Hence, the period

= 2 , while the period 2

(3 ) is computed as 2 =

of ( ) is for m=1 and k=3, namely, T=2 .

|EEE-223 | Signals & Systems Lab Manual

55

You might also like