0% found this document useful (0 votes)
12 views34 pages

Signals and Systems

This document is a laboratory manual for the Signals and Systems course at L.D. College of Engineering, detailing practical exercises completed by a student named Kathan Master. It includes a certificate of completion, an index of practicals, and various MATLAB exercises related to vector creation, operations, and flow control. The manual serves as a record of the student's work from March to June 2023.

Uploaded by

Bhoomi Jyani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views34 pages

Signals and Systems

This document is a laboratory manual for the Signals and Systems course at L.D. College of Engineering, detailing practical exercises completed by a student named Kathan Master. It includes a certificate of completion, an index of practicals, and various MATLAB exercises related to vector creation, operations, and flow control. The manual serves as a record of the student's work from March to June 2023.

Uploaded by

Bhoomi Jyani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SIGNAL AND SYSTEM

(3141005)
B.E. Sem 4th Semester

Laboratory Manual
2023

Department of Electronics & Communication Engineering


L.D. College of Engineering, Ahmedabad
CERTIFICATE

This is to certify that Mr. Kathan Master of 4th EC, Enrolment no.
220283111016 satisfactorily completed his/her term work for Signals &
Systems (3141005) within four walls of L.D. College of engineering,
Ahmedabad affiliated to Gujarat Technological University, in March 2023 to
June 2023.

Date :
Place : L.D. Collage of Engineering, Ahmedabed.

[ Subject In charge] [ Head of Department]


Pinky Bharhmbhatt C.H. Vithalani
INDEX

SR.NO. NAME OF PRACTICAL PAGE DATE SIGN


NO.
1 1.1 Creating vectors
1.2 Operate with the vectors
1.3 Using MATLAB help system
1.4 Flow Control
2
2.1 Checking result of some commands
2.2 Compare a script and a function
2.3 Plotting Continuous-Time Signals
2.4 Plotting Discrete-Time Signals
3
3.1 The conv Command
3.2 Plotting a Sampled-Signal
3.3 Convolution of Non-Causal Signals
3.4 Difference Equations
4 4.1 Find F.T. & I.F.T.of given sequences.
4.2 Find the Fourier transform of given signals
4.3 Time scaling property of F.T. for given signals
Kathan Master Enrollment No : 220283111016

Lab work-1
1. Creating vectors

(a) Generate the following vectors:

Code:

A = [1 0 4 5 3 9 0 2]
a = [4 5 0 2 0 0 7 1]

Be aware that Matlab are case sensitive. Vector A and a have different values.

Output:

A = 1 0 4 5 3 9 0 2
a = 4 5 0 2 0 0 7 1

(b) Generate the following vectors:

Code:

A = [1 0 4 5 3 9 0 2]
a = [4 5 0 2 0 0 7 1]
B = [A a]
C = [a,A]

Output:

A = 1 0 4 5 3 9 0 2
a = 4 5 0 2 0 0 7 1
B =
Columns 1 through 12
1 0 4 5 3 9 0 2 4 5 0 2
Columns 13 through 16
0 0 7 1
C =
Columns 1 through 12
4 5 0 2 0 0 7 1 1 0 4 5
Columns 13 through 16
3 9 0 2

(c) Generate the following vectors using function zeros and ones:

Code:

%zeros and ones


Z = zeros(1,50)
H = ones(1,100)

Output:

Z =
Columns 1 through 33

SIGNAL & SYSTEM E.C. 1


Kathan Master Enrollment No : 220283111016

0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0
Columns 34 through 50
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0

H =
Columns 1 through 33
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1
Columns 34 through 66
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1
Columns 67 through 99
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1
Column 100
1

(d) Generate the following vectors using the colon operator


Code:

%colon vector
F = [1:30]
k = [25:-3:1]
H = [0:0.2:2]
The colon, :, is one of Matlab’s most important operators.

Output:

F =
1 2 3 4 5 6 7 8 9 10 11 12 13 1
4 15 16 17 18 19 20 21 22 23 24 25 26 2
7 28 29 30

k = 25 22 19 16 13 10 7 4 1

H =
0 0.2000 0.4000 0.6000 0.8000 1.0000 1.2000 1.4000 1.6
000 1.8000 2.0000

2. Operate with the vectors

V1 = [1 2 3 4 5 6 7 8 9 0]
V2 = [0.3 1.2 0.5 2.1 0.1 0.4 3.6 4.2 1.7 0.9]
V3 = [4 4 4 4 3 3 2 2 2 1]

A. Calculate, respectively, the sum of all the elements in vectors V1, V2, and V3.

SIGNAL & SYSTEM E.C. 2


Kathan Master Enrollment No : 220283111016

Code:

clc;
clear all;
close all;
%EXP 1 Creating Vector
V1 = [ 1 2 3 4 5 6 7 8 9 0]
V2 = [0.3 1.2 0.5 2.1 0.1 0.4 3.6 4.2 1.7 0.9]
V3 = [4 4 4 4 3 3 2 2 2 1]
Q = sum(V2)
R = sum(V3)
P = sum(V1)

Output:

Q = 15.0000
R = 29
P = 45

B. How to get the value of the fifth element of each vector?


What happens if we execute the command V1(0) and V1(11)?
Remember if a vector has N elements, their subscripts are from 1 to N.

Ans :
To get the value of the fifth element of a vector we type a command as A = V1(5); result will be
A = 5. If we write a command A= V1(0); this will reflect error.

C. Generate a new vector V4 from V2, which is composed of the first five elements of V2.
Generate a new vector V5 from V2, which is composed of the last five elements of V2.

Code:

V2 = [0.3 1.2 0.5 2.1 0.1 0.4 3.6 4.2 1.7 0.9]
V4 = V2(1:5)
V5 = V2(6:10)

Output:

V4 = 0.3000 1.2000 0.5000 2.1000 0.1000


V5 = 0.4000 3.6000 4.2000 1.7000 0.9000

D. Derive a new vector V6 from V2, with its 6th element omitted.

Code:

V2 = [0.3 1.2 0.5 2.1 0.1 0.4 3.6 4.2 1.7 0.9]
V6 = [V2(1:5) V2(7:10)];

SIGNAL & SYSTEM E.C. 3


Kathan Master Enrollment No : 220283111016

Output:

V6 = 0.3000 1.2000 0.5000 2.1000 0.1000 3.6000


4.2000 1.7000 0.9000

E. Derive a new vector V7 from V2, with its 7th element changed to 1.4.

Code:

V2 = [0.3 1.2 0.5 2.1 0.1 0.4 3.6 4.2 1.7 0.9]
V7 = [ V2(1:6) 1.4 V2(8:10)];

Output:

V7 = 0.3000 1.2000 0.5000 2.1000 0.1000 0.4000


1.4000 4.2000 1.7000 0.9000

F. Derive a new vector V8 from V2, whose elements are the 1st, 3rd, 5th, 7th, and 9th
elements of V2

Code:

V2 = [0.3 1.2 0.5 2.1 0.1 0.4 3.6 4.2 1.7 0.9]
V8 = [V2(1:2:10)]

Output:
V8 = 0.3000 0.5000 0.1000 3.6000 1.7000

G. What are the results of

Code :

9-V1
V1*5
V1+V2
V1-V3
V1.*V2
V1*V2
V1.^2
V1.^V3
V1^V3
V1 == V3
V1>6
V1>V3
V3-(V1>2)
(V1>2) & (V1<6) (V1>2) | (V1<6)
any(V1)
all(V1)

SIGNAL & SYSTEM E.C. 4


Kathan Master Enrollment No : 220283111016

Output:

V1 = 1 2 3 4 5 6 7 8 9 0
V2 = 0.3000 1.2000 0.5000 2.1000 0.1000 0.4000
3.6000 4.2000 1.7000 0.9000
V3 = 4 4 4 4 3 3 2 2 2 1
B = 8 7 6 5 4 3 2 1 0 9
C = 5 10 15 20 25 30 35 40 45 0
D = 1.3000 3.2000 3.5000 6.1000 5.1000 6.4000 10.6000
12.2000 10.7000 0.9000
E = -3 -2 -1 0 2 3 5 6 7 -1
F = 0.3000 2.4000 1.5000 8.4000 0.5000 2.4000 25.2000
33.6000 15.3000 0
G = 1 4 9 16 25 36 49 64 81 0
H = 1 16 81 256 125 216 49 64 81 0
I =1×10 logical array
0 0 0 1 0 0 0 0 0 0
J = 1×10 logical array
0 0 0 0 0 0 1 1 1 0
K =1×10 logical array
0 0 0 0 1 1 1 1 1 0
L = 4 4 3 3 2 2 1 1 1 1
M =1×10 logical array
0 0 1 1 1 0 0 0 0 0
N =1×10 logical array
1 1 1 1 1 1 1 1 1 1
P = logical
1
O =logical
0
3. Using MATLAB help system, click on

Help -> MATLAB help or type help desk to can open the help files. For description of a single

function or command, type help command name on the command line, or use ’search’ in the help

window. For example, type help plot or help all or help any

on the command line.

4. Flow control

What are the results of these sets of commands? Think them over and run them with Matlab
to see if you are right.

(A) Code:

A = zeros(1,5);
for n = 1:4
for m = 1:3
A = A + n*m;
end

SIGNAL & SYSTEM E.C. 5


Kathan Master Enrollment No : 220283111016

end
A
Output:
A =
60 60 60 60 60

(B) Code:

B = [1 2 3 4];
if (all(B))
B = B + 1;
elseif (any(B))
B = B + 2;
else
B = B + 3;
end
B

Output:

B =
2 3 4 5

SIGNAL & SYSTEM E.C. 6


Kathan Master Enrollment No : 220283111016

LAB Work 2
(A) What are the results of these sets of commands? Think them over and run
them with Matlab to see if you are right.
(1) Code :

C = 7:2:22 Num=0;
while (all (C > 0));
C= C-3;
Num=Num+1; end
C
Num

Output:

C =
-2 0 2 4 6 8 10 12
Num =
3
(2) Situations under which loops can be avoided. Does the set of Commands:

for i = 1:20
H(i) = i *5;
end
H
have the same result as:
H= 1:20;
H= H*5;
Does the set of commands:
for n = 1:100000
x(n) = sin(n*pi/10);
end
have the same result as:
n = 1:100000;
x = sin(n*pi/10);

(B) Compare a script and a function

1) Write a script: In the main menu of Matlab, select file -> new -> M-file A new window will
pop up. Input the following commands: x = 1:5; y = 6:10; g = x+y; and then save
the file as myprogram.m under the default path matlab/work

2) Write a function: Create a new m file following the procedure of above. Type in the commands:

function g = myfunction(x,y)
g = x + y;
and then save it as myfunction.m

SIGNAL & SYSTEM E.C. 7


Kathan Master Enrollment No : 220283111016

3) Compare their usage


(1) run the commands one by one:

myprogram
x
y
g
z = myprogram (error?)

(2) Run command clear to remove all variables from memory

(3) Run the commands one by one:

x = 1:5;
y = 6:10; (error?)
z = myfunction(x,y)
g (error?)
a = 1:10;
b = 2:11;
myfunction(a,b)

(c) Plotting Continuous-Time Signals For the following:


Run the following three lines and explain why the plots are different.
For the last graph, add a title and axis labels with:

title(‘Sinusoidal Signal’)
xlabel(’t (Seconds)’) ylabel(’y(t)’)

t = 0:2*pi; plot(t,sin(t))

Graphical Output :

SIGNAL & SYSTEM E.C. 8


Kathan Master Enrollment No : 220283111016

t = 0:0.2:2*pi; plot(t,sin(t))

Graphical Output :

t = 0:0.02:2*pi; plot(t,sin(t))

Graphical Output :

Change the axis with: axis([0 2*pi -1.2 1.2])

Graphical Output :

SIGNAL & SYSTEM E.C. 9


Kathan Master Enrollment No : 220283111016

Put two plots on the same axis: t = 0:0.2:2*pi; plot(t,sin(t),t,sin(2*t))


Graphical Output :

Produce a plot without connecting the points: t = 0:0.2:2*pi; plot(t,sin(t),’.’)

Graphical Output :

SIGNAL & SYSTEM E.C. 10


Kathan Master Enrollment No : 220283111016

Try the following command: t = 0:0.2:2*pi; plot(t,sin(t),t,sin(t),’r.’)


Graphical Output:

What does the r do?

Ans. The ‘r’ in command plot(t,sin(t),t,sin(t),’r.’) changes the colour of the plot to red from
default.

(d) Plotting Discrete-Time Signals

Use stem to plot the discrete-time step-function:

n = -10:10;
f = n >= 0;
stem(n,f)

Graphical Output :

SIGNAL & SYSTEM E.C. 11


Kathan Master Enrollment No : 220283111016

Make stem plots of the following signals.


Decide for yourself what the range of n should be.

f(n) = u(n) − u(n − 4)

Code:
clc;
clear all;
close all;
n = -10:10;
u= n>=0;
u4 = n>=4;
f = u- u4;
stem(n,f)
title(' f(n) = u(n) − u(n − 4) ')
xlabel('discrete n')
ylabel('f(n)')

Graphical Output :

g(n) = n · u(n) − 2 (n − 4) · u(n − 4) + (n − 8) · u(n − 8)

Code:
clc;
clear all;
close all;
n = -10 :20;
u = n>=0;
u4 = n>=4;
u8 = n>=8;
fn = u-u4;
gn = (n.*u)-2*(n-4).*u4+(n-8).*u8;
stem(n,gn)
title(' g(n) = n · u(n) − 2 (n − 4) · u(n − 4) + (n − 8) · u(n− 8)
')

SIGNAL & SYSTEM E.C. 12


Kathan Master Enrollment No : 220283111016

xlabel('discrete n')
ylabel('g(n)')

Graphical Output :

x(n) = δ(n) − 2 δ(n − 4) y(n) = (0.9)n (u(n) − u(n − 20)) v(n) = cos(0.12 πn) u(n)

SIGNAL & SYSTEM E.C. 13


Kathan Master Enrollment No : 220283111016

Lab Work-3
1. The conv Command
Use help conv to find out how to use the conv command. Let

f(n) = u(n) − u(n − 4) g(n) = n · u(n) − 2 (n − 4) · u(n − 4) + (n − 8) · u(n − 8).

Make stem plots of the following convolutions.


Use the MATLAB conv command to compute the convolutions.
Use the commands title, xlabel, ylabel to label the axes of your plots.
(a) f(n) f(n)

Graphical Output :

(b) f(n) * f(n)* f(n)

Graphical Output :

SIGNAL & SYSTEM E.C. 14


Kathan Master Enrollment No : 220283111016

(c)f(n) g(n)

(d)g(n) δ(n)

(e)g(n) g(n)

Comment on your observations: Do you see any relationship between f(n) f(n) and g(n) ?
Compare f(n) with f(n) f(n) and with f(n) f(n) f(n).

SIGNAL & SYSTEM E.C. 15


Kathan Master Enrollment No : 220283111016

What happens as you repeatedly convolve this signal with itself?

2. Plotting a Sampled-Signal.
Suppose the continuous-time signal x(t) is sampled with a sampling period of 0.3 seconds
between each sample. Suppose also that the first sample is at t = 0 and that a total of 12 samples
are collected. The table below lists the samples of x(t) that were collected.

sample x(t)
number

0 6.0
1 -1.3
2 -8.0
3 -11.7
4 -11.0
5 -6.0
6 1.3
7 8.0
8 11.7
9 11.0
10 6.0
11 -1.3

Using the plot command, make a plot of this signal.

SIGNAL & SYSTEM E.C. 16


Kathan Master Enrollment No : 220283111016

The horizontal axis should be labeled: TIME . Make sure that the horizontal time axis shows the
correct time for each sample: 0, 0.3, 0.6, . . . , 3.3.

Smoothing Data and Difference Equations

3. Convolution of Non-Causal Signals


Use MATLAB to make stem plots of the following signals.
Decide for yourself what the range of n should be. Note that both of these signals start to the left
of
n = 0.
f(n) = {1, 2, 3,4} n = -1:2 g(n) = { 1,1,1 } n =0:2
Next, use MATLAB to make a stem plot of x(n) = f(n) g(n).

Also: plot the signals by hand without relying on MATLAB and check that you get the same
result as your MATLAB plot (not to turn in).

Exercise: Make a function in which user inputs 2 vector, do their convolution and result its plot.
Code :

clc;
clear all;
close all;
x =input('Enter The first sequance :')

SIGNAL & SYSTEM E.C. 17


Kathan Master Enrollment No : 220283111016

n1 = input('Enter the range')


if ( length(n1)~=length(x))
error (' Length is not equal')
end
y =input('Enter The second sequance :')
n2 = input('Enter the range')
if ( length(n2)~=length(y))
error (' Length is not equal')
end
n3 =min(n1)+min(n2):max(n1)+max(n2);
A = conv(x,y);
stem(n3,A)

Output:
Enter The first sequence:
[0 1 2 3]

x =
0 1 2 3

Enter the range


-1:2

n1 =

-1 0 1 2

Enter The second sequence :


[1 2 3 4]

y =
1 2 3 4

Enter the range


0:3

n2 =
0 1 2 3
Graphical Output :

SIGNAL & SYSTEM E.C. 18


Kathan Master Enrollment No : 220283111016

To turn in: The plots of f(n), g(n), x(n), and your MATLAB commands to create these signals and plots.
f(n) = 3 δ(n + 2) − δ(n − 1) + 2 δ(n − 3)
g(n) = u(n + 4) − u(n − 3)
x(n) = f(n) g(n).
Code :
%KATHAN MASTER (220283111016)
clc;
clear all;
close all;
n=-10:10;
f=3*(n==-2)-(n==1)+2*(n==3);
g=(n>=-4)-(n>=3);
A=conv(f,g);
n2=min(n)+min(n):max(n)+max(n);
stem(n2,A);

Graphical Output:

SIGNAL & SYSTEM E.C. 19


Kathan Master Enrollment No : 220283111016

4. Difference Equations
Suppose a system is implemented with the difference equation:
y(n) = x(n) + 2 x(n − 1) − 0.95 y(n − 1)
Write your own MATLAB function, mydiffeq, to implement this difference equation using a for
loop. (Type help for to see how to use the for loop.) If the input signal is N-samples long (0 ≤ n ≤
N − 1), your program should find the first N sample of the output y(n) (0 ≤ n ≤ N − 1).
Remember that MATLAB indexing starts with 1, not 0, but don’t let this confuse you. Use x(−1)
= 0 and y(−1) = 0.

Code :

function y=mydiffeq(x)
y(1)=x(1)
for n=2:length(x);
y(n)=x(n)+2*x(n-1)-0.95*y(n-1)
end

To see how to write a MATLAB function see the MATLAB Getting Started Guide. This tutorial
to MATLAB is very useful
(a)Is this system linear? Use your MATLAB function to confirm your answer:
y1 = mydiffeq(x1)
y2 = mydiffeq(x2)
y3 = mydiffeq(x1+2*x2)
Use any signals x1, x2 you like.

Code :
x=1:10
y=mydiffeq(x)
x1=1:5;
x2=6:10;
a=3;
b=4;
y1=mydiffeq(x1);
y2=mydiffeq(x2);
c=a*x1+b*x2;
y3=mydiffeq(c);
y4=a*y1+b*y2;
subplot(2,1,1);
stem(y3);
title('o/p to weighted sum of input')
xlabel('time')
ylabel('amplitude')

SIGNAL & SYSTEM E.C. 20


Kathan Master Enrollment No : 220283111016

subplot(2,1,2);
stem(y4);
title('weighted sum of output')
xlabel('time')
ylabel('amplitude')

Output:
pr3_difference

x = 1 2 3 4 5 6 7 8 9 10

y = 1

y = 1.0000 3.0500

y = 1.0000 3.0500 4.1025

y = 1.0000 3.0500 4.1025 6.1026

y = 1.0000 3.0500 4.1025 6.1026 7.2025

y = 1.0000 3.0500 4.1025 6.1026 7.2025 9.1576

y = 1.0000 3.0500 4.1025 6.1026 7.2025 9.1576 10.3003

y = 1.0000 3.0500 4.1025 6.1026 7.2025 9.1576 10.3003


12.2148

y = 1.0000 3.0500 4.1025 6.1026 7.2025 9.1576 10.3003


12.2148 13.3960

y = 1.0000 3.0500 4.1025 6.1026 7.2025 9.1576 10.3003


12.2148 13.3960 15.2738

y = 1.0000 3.0500 4.1025 6.1026 7.2025 9.1576 10.3003


12.2148 13.3960 15.2738

y = 1
y = 1.0000 3.0500

y = 1.0000 3.0500 4.1025

SIGNAL & SYSTEM E.C. 21


Kathan Master Enrollment No : 220283111016

y = 1.0000 3.0500 4.1025 6.1026

y = 1.0000 3.0500 4.1025 6.1026 7.2025

y = 6

y = 6.0000 13.3000

y = 6.0000 13.3000 9.3650

y = 6.0000 13.3000 9.3650 16.1033

y = 6.0000 13.3000 9.3650 16.1033 12.7019

y = 27

y = 27.0000 62.3500

y = 27.0000 62.3500 49.7675

y = 27.0000 62.3500 49.7675 82.7209

y = 27.0000 62.3500 49.7675 82.7209 72.4152

Graphical Output :

SIGNAL & SYSTEM E.C. 22


Kathan Master Enrollment No : 220283111016

(b) Is this system time-invariant? Confirm this in MATLAB (how?).


Code :
clc;
clear all;
close all;
x = 1:5;
d =3;
y = mydiffeq(x);
xd = [zeros(1,d) x];
y1 = mydiffeq(xd);
yd = [zeros(1,d) y];
subplot(2,1,1);
stem(y1);
title('o/p due to weighted sum of i/ps ');
xlabel(' discrete n');
ylabel('Amplitude');
subplot(2,1,2);
stem(yd);
title(' weighted sum of o/ps ');
xlabel(' discrete n');
ylabel('Amplitude')

Output:
y = 1
y = 1.0000 3.0500
y = 1.0000 3.0500 4.1025
y = 1.0000 3.0500 4.1025 6.1026
y = 1.0000 3.0500 4.1025 6.1026 7.2025
y = 0
y = 0 0
y = 0 0 0
y = 0 0 0 1
y = 0 0 0 1.0000 3.0500
y = 0 0 0 1.0000 3.0500 4.1025
y = 0 0 0 1.0000 3.0500 4.1025 6.1026
y = 0 0 0 1.0000 3.0500 4.1025 6.1026 7.2025

Graphical Output :

SIGNAL & SYSTEM E.C. 23


Kathan Master Enrollment No : 220283111016

(c)Compute and plot the impulse response of this system.


Use x = [1, zeros(1,100)]; as input.
(d) Define x(n) = cos(π n/8) [u(n) − u(n − 50)].
Compute the output of the system in two ways: (1) y(n) = h(n) x(n) using the conv command. (2)
Use your function to find the output for this input signal. Are the two output signals you compute
the same?
(e) Write a new MATLAB function for the system with the difference equation:
y(n) = x(n) + 2 x(n − 1)
Find and plots the impulse response of this system. What is the difference between the two
impulse responses?
(f) Write a new MATLAB function for the system with the difference equation:
y(n) = x(n) + 2 x(n − 1) − 1.1 y(n − 1)
Find and plots the impulse response of this system. What do you find? Discuss your
observations.
To turn in: The plots, your MATLAB commands to create the signals and plots, and discussion.

SIGNAL & SYSTEM E.C. 24


Kathan Master Enrollment No : 220283111016

Lab work-4
Fourier Transform

1. Find the Fourier transform and Inverse Fourier transform of given sequences.

Use syms, fourier and ifourier functions in Matlab.


Get your answer on command window.
a) x1(t) = e^ (-t2)
b) x2(t) = e-at u(t)
c) x3(t) = eat u(-t)

Code :
clc;
clear all;
close all;
syms t a w;
x1 = exp(-t^2);
subplot(331);
fplot(x1);
title('Input Signal x1');
xlabel('t(seconds)');
ylabel('Amplitude');
x2 = exp(-2*t)*heaviside(t);
subplot(332);
fplot(x2);
title('Input Signal x2');
xlabel('t(seconds)');
ylabel('Amplitude');
x3 = exp(2*t)*heaviside(-t);
subplot(333);
fplot(x3);
title('Input Signal x3');
xlabel('t(seconds)');
ylabel('Amplitude');
X1 = fourier(x1);
X2 = fourier(x2);
X3 = fourier(x3);
x1 = ifourier(X1);
x2 = ifourier(X2);
x3 = ifourier(X3);
subplot(334);
fplot(X1);
title('F.T. of x1');
xlabel('t(seconds)');
ylabel('Amplitude');
subplot(335);
fplot(abs(X2));
title('F.T. of x2');
xlabel('t(seconds)');

SIGNAL & SYSTEM E.C. 25


Kathan Master Enrollment No : 220283111016

ylabel('Amplitude');
subplot(336);
fplot(abs(X3));
title('F.T. of x3');
xlabel('t(seconds)');
ylabel('Amplitude');
subplot(337);
fplot(x1);
title('[F.T.]^-1 of X1');
xlabel('t(seconds)');
ylabel('Amplitude');
subplot(338);
fplot(x2);
title('[F.T.]^-1 of X2');
xlabel('t(seconds)');
ylabel('Amplitude');
subplot(339);
fplot(x3);
title('[F.T.]^-1 of X3');
xlabel('t(seconds)');
ylabel('Amplitude');

Graphical Output :

SIGNAL & SYSTEM E.C. 26


Kathan Master Enrollment No : 220283111016

2. Find the Fourier transform of given signals.


Use syms, heaviside, simplify, fplot functions in Matlab.
Get the plot of input signal, its Fourier transform and magnitude response.
a) x1(t) = 2*rect(t/4)
Code :
clc;
clear all;
close all;
syms t w;
x1 = 2 *(heaviside(t+2)-heaviside(t-2));
X1 = simplify(fourier(x1));
mag_X1 = abs(X1);
%figure;
subplot(2, 2, 1);
axis([-5 5 0 5]);
fplot(x1);
title('I/P signal x1(t)');
xlabel('t(seconds)');
ylabel('x1(t)');
subplot(2, 2, 2);
fplot(X1);
title('F[Simplified I/P]');
xlabel('w');
ylabel('X1(w)');
subplot(2, 2, 3);
fplot(mag_X1, [-10 10]);
title('Magnitude of X1(w)');
xlabel('w');
ylabel('Magnitude |X1(w)|');

Graphical Output :

SIGNAL & SYSTEM E.C. 27


Kathan Master Enrollment No : 220283111016

b) x2(t) = e-2t u(t)


Code :
clc;
clear all;
close all;
syms t w
x2 = exp(-2*t) * heaviside(t);
X2 = simplify(fourier(x2));
magnitude_X2 = abs(X2);
%figure;
subplot(2, 2, 1);
fplot(x2, [-5 5]);
title('I/P Signal x2(t)');
xlabel('t(seconds)');
ylabel('x2(t)');
subplot(2, 2, 2);
fplot(X2, [-10 10]);
title('F[simplified x2(t)]');
xlabel('w');
ylabel('X2(w)');
subplot(2, 2, 3);
fplot(magnitude_X2, [-10 10]);
title('Mag of X2(w)');
xlabel('w');
ylabel('|X2(w)|');

Graphical Output :

SIGNAL & SYSTEM E.C. 28


Kathan Master Enrollment No : 220283111016

3. Time scaling property of Fourier transform for given signals.


Use syms, heaviside, simplify, fplot functions in Matlab.
Get the plot of input signals(without and with scaling) , its Fourier transforms(without and
with scaling).
a) Sinc signal
Code :
syms t f
% Sinc Signal
x_sinc = sinc(t);
subplot(2, 2, 1)
fplot(x_sinc, [-10, 10])
xlabel('t')
ylabel('x(t)')
title('Original Sinc Signal')
%Fourier transform of the original sinc signal
X_sinc = simplify(fourier(x_sinc));
subplot(2, 2, 2)
fplot(abs(X_sinc), [-10, 10])
xlabel('f')
ylabel('X(f)')
title('Fourier Transform of Original Sinc Signal')
% Time scaling of sinc signal
a = 2;
x_sinc_scaled = subs(x_sinc, t, t/a);
subplot(2, 2, 3)
fplot(x_sinc_scaled, [-20, 20])
xlabel('t')
ylabel('x(t/a)')
title('Scaled Sinc Signal')
% Compute the Fourier transform of the scaled sinc signal
X_sinc_scaled = simplify(fourier(x_sinc_scaled));
subplot(2, 2, 4)
fplot(abs(X_sinc_scaled), [-10, 10])
xlabel('f')
ylabel('X(f/a)')
title('Fourier Transform of Scaled Sinc Signal')

SIGNAL & SYSTEM E.C. 29


Kathan Master Enrollment No : 220283111016

Graphical Output :

b) Rectangular signal
Code :
syms t f
% Sinc Signal
x_sinc = sinc(t);
subplot(2, 2, 1)
fplot(x_sinc, [-10, 10])
xlabel('t')
ylabel('x(t)')
title('Original Sinc Signal')
%Fourier transform of the original sinc signal
X_sinc = simplify(fourier(x_sinc));
subplot(2, 2, 2)
fplot(abs(X_sinc), [-10, 10])
xlabel('f')
ylabel('X(f)')
title('Fourier Transform of Original Sinc Signal')
% Time scaling of sinc signal
a = 2;
x_sinc_scaled = subs(x_sinc, t, t/a);
subplot(2, 2, 3)
fplot(x_sinc_scaled, [-20, 20])
xlabel('t')
ylabel('x(t/a)')
title('Scaled Sinc Signal')
% Compute the Fourier transform of the scaled sinc signal
X_sinc_scaled = simplify(fourier(x_sinc_scaled));
subplot(2, 2, 4)
fplot(abs(X_sinc_scaled), [-10, 10])
xlabel('f')
ylabel('X(f/a)')

SIGNAL & SYSTEM E.C. 30


Kathan Master Enrollment No : 220283111016

title('Fourier Transform of Scaled Sinc Signal')

Graphical Output :

SIGNAL & SYSTEM E.C. 31

You might also like