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

SS LAB MANUAL_D23 FINAL

Uploaded by

naveen
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 views

SS LAB MANUAL_D23 FINAL

Uploaded by

naveen
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/ 42

SIGNALS AND SYSTEMS LAB

II Year-II Semester 2024-25

Name of the Student : ………………………………………………………..

Roll. Number : ………………………………………………………..

Class & Section : ………………………………………………………..

Branch : ……………………………………………………….

Department of Electronics & Communication Engineering


Dhanekula Institute of Engineering &Technology
Autonomous
Approved by AICTE New Delhi, Permanently Affiliated to JNTU
Kakinada AnISO9001-2015CertifiedInstitution&NBA Accredited (EEE, ME,
ECE &CSE)
Ganguru, Vijayawada–521139
Dhanekula Institute of Engineering &Technology
AUTONOMOUS
Approved by AICTE New Delhi, Permanently Affiliated to JNTU
Kakinada AnISO9001-2015CertifiedInstitution&NBA Accredited (EEE, ME,
ECE &CSE)
Ganguru, Vijayawada–521139

This is to certify that this is the Bonafide work done by

Mr./Miss…………………………………………….. Bearing Roll No………………………..

…..of………………….B. Tech in......................................................................................................for the

Laboratory course................................................................................................................................during the

Academic year……………………………..

No. of Experiments done: ……………

………………………………………..
Signature of the Course Coordinator
INDEX

S. No Date Name of the Experiment Marks Signature

10

Average Marks:
Dhanekula Institute of Engineering &Technology
AUTONOMOUS
Approved by AICTE New Delhi, Permanently Affiliated to JNTU Kakinada
An ISO9001-2015 Certified Institution& NBA Accredited (EEE, ME, ECE &CSE)
Ganguru, Vijayawada – 521139
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Knowledge
Course Outcomes: At the end of the course, student will be able to Level(K)#
CO1 Demonstrate an understanding of basic signals and their characteristics by generating and
visualizing various analog and discrete-time signals. Understand
CO2
Apply mathematical operations such as addition, subtraction, multiplication, and division to Applying
signals, and interpret their significance in signal processing.
CO3
Understanding of even and odd signal properties. Understand
CO4
Analyze transformations of signals, including shifting, scaling, and reversing, and evaluate the
Analyzing
impact of these transformations on signal properties.
CO5
Evaluate signal relationships using convolution, correlation, Fourier analysis, and Z-transforms Evaluate
to extract meaningful insights from signals.

Course Out P01 P02 P03 P04 P05 P06 P07 P08 P09 P010 P011 P012 PSO1 PSO2
Come
CO1 3 2 1 - 2 3 3
CO2 3 3 2 2 3 3 3
CO3 2 2 1 - 1 3 3
CO4 2
3 3 3 2 3 3
CO5 3
3 3 3 3 3 3
Level of 3 3 2 2 2 3 3
Mapping

S.No Experiments Hours


1 Generation of Basic Signals (Analog and Discrete) 1. Unit step 2. Unit impulse 3. Unit Ramp 4. 3
Sinusoidal 5.Signum
2 Operations on signals 1. Addition & Subtraction 2. Multiplication & Division,3. Maximum & 3
minimum
3 Energy and power of signals,even and odd signals 3

4 Transformation of the independent variable 3


Shifting (Delay & Advance)
Reversing
Scaling
5 Convolution & Deconvolution 3

6 Correlation 3
7 Fourier Series Representation 3
8 Fourier Transform and Analysis of Fourier Spectrum 3
9 Laplace Transforms 3

10 Z -Transforms 3
Exp No:1 Date:

Generation of Basic Signals (Analog and Discrete) 1. Unit step 2. Unit


impulse 3. Unit Ramp 4. Sinusoidal 5.Signum
AIM:
To Generate Basic Signals (Analog and Discrete) 1. Unit step 2. Unit impulse 3. Unit Ramp 4. Sinusoidal
5.Signum
APPARATUS REQUIRED: 1. Computer
2. Python 3.13
THEORY: Anything that carries information can be called as signal. It can also be defined as a
physical quantity that varies with time, temperature, pressure or with any independent variables.The
process of operation in which the characteristics of a signal (Amplitude, shape, phase, frequency,
etc.) undergoes a change is known as signal processing.
Continuous-time signals are defined along a continuum of time and are thus, represented by a
continuous independent variable The signals, which are defined at discrete times are known as discrete
signals. Unit Impulse Sequence:

It is denoted as δ(n) in discrete time domain and can be defined as

Unit Step Signal


Discrete time unit step signal is defined as

The figure above shows the graphical representation of a discrete step function.
Unit Ramp Function
A discrete unit ramp function can be defined as

Discrete time Sinusoidal Signal


All continuous-time signals are periodic. The discrete-time sinusoidal sequences may or may
not be periodic. They depend on the value of ω. For a discrete time signal to be periodic, the angular
frequency ω must be a rational multiple of 2π.
A discrete sinusoidal signal is shown in the figure above.
Discrete form of a sinusoidal signal can be represented in the format

1
Here A,ω and φ have their usual meaning and n is the integer. Time period of the discrete
sinusoidal signal is given by

Code:
import numpy as np
import matplotlib.pyplot as plt

# User Inputs
start_time = float(input("Enter the start time: "))
end_time = float(input("Enter the end time: "))
freq = float(input("Enter the frequency for the sinusoidal signal: "))
num_points = 400 # Default number of points

# Generate Time Array


t = np.linspace(start_time, end_time, num_points)

# Signals
u_step = np.heaviside(t, 1) # Unit Step
u_impulse = np.zeros_like(t)
u_impulse[np.abs(t).argmin()] = 1 # Approximated Impulse
u_ramp = np.maximum(0, t) # Unit Ramp
sin_wave = np.sin(2 * np.pi * freq * t) # Sinusoidal
signum = np.sign(t) # Signum

# Plotting
signals = [(u_step, "Unit Step"), (u_impulse, "Unit Impulse"),
(u_ramp, "Unit Ramp"), (sin_wave, "Sinusoidal"), (signum, "Signum")]

plt.figure(figsize=(15, 10))
for i, (signal, title) in enumerate(signals, start=1):
plt.subplot(3, 2, i)
plt.bar(t, signal, width=0.1)
plt.title(title)
plt.xlabel("Time")
plt.ylabel("Amplitude")
plt.legend()
plt.tight_layout()
plt.show()

2
Sample Output:

RESULT:

Signature of Faculty

3
Exp No:2 Date:

Operations on signals 1. Addition & Subtraction 2. Multiplication & Division,3. Maximum & minimum

AIM: To perform operations on signals: 1. Addition and subtraction; 2. Multiplication and division.
3.Maximum & minimum
APPARATUS REQUIRED: 1. Computer
2. Python 3.13
THEORY:

1. Addition & Subtraction

o Signals can be added or subtracted point-wise. If x1(t) and x2(t) are two signals,
their addition is x(t)=x1(t)+x2(t), and subtraction is x(t)=x1(t)−x2(t).

o These operations combine the information from both signals and can be used for
superposition or finding differences.

2. Multiplication & Division

o Multiplication: The point-wise product of two signals is x(t)=x1(t)⋅x2(t). It


emphasizes regions where both signals are non-zero.

o Division: For division, x(t)=x1(t)x2(t) , it is defined only when x2(t)≠0. It is often


used for normalization or scaling purposes.

3. Maximum & Minimum

o The maximum of two signals is determined point-wise as x(t)=max(x1(t),x2(t)),


while the minimum is x(t)=min(x1(t),x2(t)).

o These operations are useful for envelope detection, clipping, or comparisons


between signals.

These operations are foundational in signal processing, enabling signal analysis, transformation,
and manipulation.

4
Code for Addition and subtraction

import numpy as np

import matplotlib.pyplot as plt

# User Inputs

start_time = float(input("Enter the start time: "))

end_time = float(input("Enter the end time: "))

freq1 = float(input("Enter the frequency for signal 1: "))

freq2 = float(input("Enter the frequency for signal 2: "))

num_points = 400 # Default number of points

# Generate Time Array

t = np.linspace(start_time, end_time, num_points)

signal1 = np.sin(2 * np.pi * freq1 * t)

signal2 = np.cos(2 * np.pi * freq2 * t)

# Operations

addition = signal1 + signal2

subtraction = signal1 - signal2

# Plotting

plt.figure(figsize=(10, 5))

plt.subplot(1, 2, 1)

plt.bar(t, addition, width=0.1)

plt.title("Addition")

5
plt.xlabel("Time")

plt.ylabel("Amplitude")

plt.subplot(1, 2, 2)

plt.bar(t, subtraction, width=0.1)

plt.title("Subtraction")

plt.xlabel("Time")

plt.ylabel("Amplitude")

plt.tight_layout()

plt.show()

Sample Output

6
Code for multiplication and division

import numpy as np

import matplotlib.pyplot as plt

# User Inputs

start_time = float(input("Enter the start time: "))

end_time = float(input("Enter the end time: "))

freq1 = float(input("Enter the frequency for signal 1: "))

freq2 = float(input("Enter the frequency for signal 2: "))

num_points = 400 # Default number of points

# Generate Time Array

t = np.linspace(start_time, end_time, num_points)

signal1 = np.sin(2 * np.pi * freq1 * t)

signal2 = np.cos(2 * np.pi * freq2 * t)

# Operations: Addition, Subtraction, Multiplication, Division

addition = signal1 + signal2

subtraction = signal1 - signal2

multiplication = signal1 * signal2

7
division = np.divide(signal1, signal2, out=np.zeros_like(signal1), where=signal2 != 0) # Handle
division by zero

# Plotting

plt.figure(figsize=(12, 10))

# Plot Addition

plt.subplot(2, 2, 1)

plt.bar(t, addition, width=0.1)

plt.title("Addition of Signals")

plt.xlabel("Time")

plt.ylabel("Amplitude")

# Plot Subtraction

plt.subplot(2, 2, 2)

plt.bar(t, subtraction, width=0.1)

plt.title("Subtraction of Signals")

plt.xlabel("Time")

plt.ylabel("Amplitude")

# Plot Multiplication

plt.subplot(2, 2, 3)

plt.bar(t, multiplication, width=0.1)

plt.title("Multiplication of Signals")

plt.xlabel("Time")

plt.ylabel("Amplitude")

8
# Plot Division

plt.subplot(2, 2, 4)

plt.bar(t, division, width=0.1)

plt.title("Division of Signals")

plt.xlabel("Time")

plt.ylabel("Amplitude")

# Adjust layout

plt.tight_layout()

plt.show()

Sample Output:

CODE FOR Maximum & minimum

import numpy as np
import matplotlib.pyplot as plt

# User Inputs
start_time = float(input("Enter the start time: "))
end_time = float(input("Enter the end time: "))
freq1 = float(input("Enter the frequency for signal 1: "))
freq2 = float(input("Enter the frequency for signal 2: "))
num_points = 400 # Default number of points

# Generate Time Array


9
t = np.linspace(start_time, end_time, num_points)
signal1 = np.sin(2 * np.pi * freq1 * t)
signal2 = np.cos(2 * np.pi * freq2 * t)

# Maximum and Minimum


max_signal = np.maximum(signal1, signal2)
min_signal = np.minimum(signal1, signal2)

# Display Results
print("Maximum Signal Values:\n", max_signal)
print("Minimum Signal Values:\n", min_signal)

# Plotting
plt.figure(figsize=(12, 6))

# Plot Maximum
plt.subplot(1, 2, 1)
plt.bar(t, max_signal, width=0.1)
plt.title("Maximum of Signals")
plt.xlabel("Time")
plt.ylabel("Amplitude")

# Plot Minimum
plt.subplot(1, 2, 2)
plt.bar(t, min_signal, width=0.1)
plt.title("Minimum of Signals")
plt.xlabel("Time")
plt.ylabel("Amplitude")

plt.tight_layout()
plt.show()

Sample Output:

10
RESULT:

Signature of Faculty

11
Exp No:3 Date:

Energy and power of signals, even and odd signals

AIM: To generate signals with defined energy, power, and even/odd characteristics.

APPARATUS REQUIRED: 1. Computer


2. Python 3.13
THEORY: Energy and Power of Signals
1. Energy Signals
o A signal is an energy signal if its total energy E is finite.

2. Power Signals

Even and Odd Signals


1. Even Signals
o A signal x(t) is even if it satisfies x(t)=x(−t).
o Symmetric about the vertical axis, examples include cosine cos(t)
o For discrete-time signals, x[n]=x[−n]

12
2. Odd Signals
o A signal x(t) is odd if it satisfies x(t)=−x(−t).
o Anti-symmetric about the origin, examples include sine sin(t).
o For discrete-time signals, x[n]=−x[−n].

Code:
import numpy as np
import matplotlib.pyplot as plt

# User inputs
start_time = float(input("Enter the start time: "))
end_time = float(input("Enter the end time: "))
frequency = float(input("Enter the frequency for the sinusoidal signal: "))

# Discrete time range


n_values = np.arange(start_time, end_time, 0.01) # Time steps

# Define the sinusoidal signal


signal = np.sin(2 * np.pi * frequency * n_values) # Sinusoidal signal

# Calculate energy of the signal


energy = np.sum(np.abs(signal) ** 2) # Energy is the sum of squared magnitudes

# Calculate power of the signal


power = np.mean(np.abs(signal) ** 2) # Power is the mean of squared magnitudes

# Check for evenness and oddness


is_even = np.allclose(signal, np.flip(signal)) # Check if signal is even
is_odd = np.allclose(signal, -np.flip(signal)) # Check if signal is odd

13
# Output results
print(f"Energy of the signal: {energy}")
print(f"Power of the signal: {power}")
print(f"Is the signal even? {'Yes' if is_even else 'No'}")
print(f"Is the signal odd? {'Yes' if is_odd else 'No'}")

# Plot the signal


plt.figure(figsize=(10, 6))
plt.plot(n_values, signal, label="Signal")
plt.title("Signal Plot")
plt.xlabel("Time")
plt.ylabel("Amplitude")
plt.legend()
plt.grid(True)
plt.show()

Sample Output:

RESULT:

14
Signature of Faculty

Exp No:4 Date:

Transformation of the independent variable 1.Shifting (Delay &


Advance),2.Reversing,3.Scaling
AIM: To perform operations on signals: 1. Addition and subtraction; 2. Multiplication and

division.

APPARATUS REQUIRED: 1. Computer


2. Python 3.13
THEORY:

15
1.Shifting (Delay & Advance)
Code
import numpy as np
import matplotlib.pyplot as plt

# User Inputs
start_time = float(input("Enter the start time: "))
end_time = float(input("Enter the end time: "))
freq = float(input("Enter the frequency for the sinusoidal signal: "))
num_points = 400 # Default number of points

# Generate Time Array


t = np.linspace(start_time, end_time, num_points)
signal = np.sin(2 * np.pi * freq * t) # Sinusoidal signal (Sine wave)

# Shifting (Delay & Advance)


shifted_delay = np.sin(2 * np.pi * freq * (t - 1)) # Delay by 1 unit
shifted_advance = np.sin(2 * np.pi * freq * (t + 1)) # Advance by 1 unit

# Plotting the Results


plt.figure(figsize=(10, 5))

# Plot Shifting - Delay


plt.subplot(1, 2, 1)
plt.bar(t, shifted_delay, width=0.1)
plt.title("Shifted Signal (Delay by 1 unit)")
plt.xlabel("Time")
plt.ylabel("Amplitude")

16
# Plot Shifting - Advance
plt.subplot(1, 2, 2)
plt.bar(t, shifted_advance, width=0.1)
plt.title("Shifted Signal (Advance by 1 unit)")
plt.xlabel("Time")
plt.ylabel("Amplitude")

# Show plot
plt.tight_layout()
plt.show()

Sample Output:

2. Reversing
Code
import numpy as np
import matplotlib.pyplot as plt
17
# User Inputs
start_time = float(input("Enter the start time: "))
end_time = float(input("Enter the end time: "))
freq = float(input("Enter the frequency for the sinusoidal signal: "))
num_points = 400 # Default number of points

# Generate Time Array


t = np.linspace(start_time, end_time, num_points)
signal = np.sin(2 * np.pi * freq * t) # Sinusoidal signal (Sine wave)

# Reversing the Signal


reversed_signal = np.sin(2 * np.pi * freq * (-t)) # Reverse the time axis

# Plotting the Results


plt.figure(figsize=(6, 5))

# Plot Reversing the Signal


plt.bar(t, reversed_signal, width=0.1)
plt.title("Reversed Signal")
plt.xlabel("Time")
plt.ylabel("Amplitude")

# Show plot
plt.tight_layout()
plt.show()

Sample Output:

3. Scaling
Code
import numpy as np
import matplotlib.pyplot as plt

# User Inputs
18
start_time = float(input("Enter the start time: "))
end_time = float(input("Enter the end time: "))
freq = float(input("Enter the frequency for the sinusoidal signal: "))
num_points = 400 # Default number of points

# Generate Time Array


t = np.linspace(start_time, end_time, num_points)
signal = np.sin(2 * np.pi * freq * t) # Sinusoidal signal (Sine wave)

# Scaling the time variable (Scale by a factor of 2)


scaled_signal = np.sin(2 * np.pi * freq * (t / 2)) # Scale by 2 (stretch the time)

# Plotting the Results


plt.figure(figsize=(6, 5))

# Plot Scaling the Signal


plt.bar(t, scaled_signal, width=0.1)
plt.title("Scaled Signal (Time stretched by factor of 2)")
plt.xlabel("Time")
plt.ylabel("Amplitude")

# Show plot
plt.tight_layout()
plt.show()

19
Sample Output:

RESULT:

Signature of Faculty

20
Exp No:5 Date:

Convolution & Deconvolution


AIM: To perform operations on signals: 1. Addition and subtraction; 2. Multiplication and division.

APPARATUS REQUIRED: 1. Computer


2. Python 3.13
THEORY:

21
Code
import numpy as np
import matplotlib.pyplot as plt
from scipy.fft import fft, ifft # Import FFT and IFFT for frequency-domain operations

# User Inputs
start_time = float(input("Enter the start time: "))
end_time = float(input("Enter the end time: "))
freq = float(input("Enter the frequency for the sinusoidal signal: "))
num_points = 400 # Default number of points for the time array

# Generate Time Array


t = np.linspace(start_time, end_time, num_points)

# Create a Sinusoidal Signal


sinusoidal_signal = np.sin(2 * np.pi * freq * t) # Sinusoidal signal (Sine wave)

# Create a Rectangular Pulse Signal


pulse_signal = np.zeros_like(t) # Initialize a zero array for the pulse signal
pulse_signal[int(num_points/4):int(3*num_points/4)] = 1 # A rectangular pulse between 1/4
and 3/4 of the time

# Perform Convolution
convolved_signal = np.convolve(sinusoidal_signal, pulse_signal, mode='same') #
Convolution of both signals

# Fourier Transform of Signals


sinusoidal_signal_fft = fft(sinusoidal_signal) # Fourier Transform of the sinusoidal signal
pulse_signal_fft = fft(pulse_signal) # Fourier Transform of the pulse signal
convolved_signal_fft = fft(convolved_signal) # Fourier Transform of the convolved signal

# Perform Division in the Frequency Domain (Deconvolution)


# Avoid division by zero by adding a small epsilon to pulse_signal_fft
epsilon = 1e-10
deconvolved_signal_fft = convolved_signal_fft / (pulse_signal_fft + epsilon) #
Deconvolution by dividing in frequency domain

# Inverse Fourier Transform to get the deconvolved signal back in the time domain
deconvolved_signal = np.real(ifft(deconvolved_signal_fft)) # Use IFFT to get the
deconvolved signal

# Plotting the Results


plt.figure(figsize=(12, 8))

# Plot Original Sinusoidal Signal


plt.subplot(2, 2, 1)
plt.plot(t, sinusoidal_signal, label='Sinusoidal Signal')
plt.title("Original Sinusoidal Signal")
22
plt.xlabel("Time")
plt.ylabel("Amplitude")
plt.legend()

# Plot Rectangular Pulse Signal


plt.subplot(2, 2, 2)
plt.plot(t, pulse_signal, label='Rectangular Pulse', color='r')
plt.title("Rectangular Pulse Signal")
plt.xlabel("Time")
plt.ylabel("Amplitude")
plt.legend()

# Plot Convolved Signal


plt.subplot(2, 2, 3)
plt.plot(t, convolved_signal, label='Convolved Signal', color='g')
plt.title("Convolution of Signals")
plt.xlabel("Time")
plt.ylabel("Amplitude")
plt.legend()

# Plot Deconvolved Signal


plt.subplot(2, 2, 4)
plt.plot(t[:len(deconvolved_signal)], deconvolved_signal, label='Deconvolved Signal',
color='orange')
plt.title("Deconvolution of Convolved Signal")
plt.xlabel("Time")
plt.ylabel("Amplitude")
plt.legend()
# Adjust layout
plt.tight_layout()
plt.show()

23
Sample Output:

RESULT:

Signature of Faculty

24
Exp No:6 Date:

Correlation
AIM: To perform correlation of signals

APPARATUS REQUIRED: 1. Computer


2. Python 3.13
THEORY:
The correlation of two functions or signals or waveforms is defined as the measure of similarity
between those signals. There are two types of correlations −
 Cross-correlation
 Autocorrelation

Cross-correlation

The cross-correlation between two different signals or functions or waveforms is defined as the measure of
similarity or coherence between one signal and the time-delayed version of another signal. The cross-
correlation between two different signals indicates the degree of relatedness between one signal and the
time-delayed version of another signal.The cross-correlation of energy (or aperiodic) signals and power (or
periodic) signals is defined separately.

Cross-correlation: Consider two signals x1(t) and x2(t) of finite energy. Then, the cross-correlation of
these two energy signals is defined as

Code:
import numpy as np
import matplotlib.pyplot as plt

# User Inputs
start_time = float(input("Enter the start time: "))
end_time = float(input("Enter the end time: "))
freq = float(input("Enter the frequency for the sinusoidal signal: "))
num_points = 400 # Default number of points for the time array

# Generate Time Array


t = np.linspace(start_time, end_time, num_points)

# Create Two Signals: A Sinusoidal Signal and a Delayed Sinusoidal Signal


sinusoidal_signal = np.sin(2 * np.pi * freq * t) # Sinusoidal signal (Sine wave)
delayed_signal = np.roll(sinusoidal_signal, 50) # Delay the sinusoidal signal by 50 samples

25
# Compute the Cross-Correlation between the Two Signals
correlation_signal = np.correlate(sinusoidal_signal, delayed_signal, mode='same') # Cross-correlation

# Plotting the Results


plt.figure(figsize=(12, 8))

# Plot Original Sinusoidal Signal


plt.subplot(2, 2, 1)
plt.plot(t, sinusoidal_signal, label='Original Sinusoidal Signal')
plt.title("Original Sinusoidal Signal")
plt.xlabel("Time")
plt.ylabel("Amplitude")
plt.legend()

# Plot Delayed Sinusoidal Signal


plt.subplot(2, 2, 2)
plt.plot(t, delayed_signal, label='Delayed Sinusoidal Signal', color='r')
plt.title("Delayed Sinusoidal Signal")
plt.xlabel("Time")
plt.ylabel("Amplitude")
plt.legend()

# Plot Cross-Correlation Signal


plt.subplot(2, 2, 3)
plt.plot(t, correlation_signal, label='Cross-Correlation Signal', color='g')
plt.title("Cross-Correlation of Signals")
plt.xlabel("Time")
plt.ylabel("Amplitude")
plt.legend()

# Adjust layout
plt.tight_layout()
plt.show()

26
SAMPLE OUTPUT:

RESULT:

Signature of Faculty

Exp No:7 Date:

27
Fourier Series Representation
AIM: To represent a signal using Fourier series.

APPARATUS REQUIRED: 1. Computer


2. Python 3.13
THEORY:
A Fourier series is an expansion of a periodic function f(x) in terms of an infinite sum of sines
and cosines. Fourier series make use of the orthogonality relationships of the sine and cosine
functions. The computation and study of Fourier series is known as harmonic analysis and is
extremely useful as a way to break up an arbitrary periodic function into a set of simple terms
that can be plugged in, solved individually, and then recombined to obtain the solution to the
original problem or an approximation to it to whatever accuracy is desired or practical.
Examples of successive approximations to common functions using Fourier series are illustrated
above.

In particular, since the superposition principle holds for solutions of a linear homogeneous
ordinary differential equation, if such an equation can be solved in the case of a single sinusoid,
the solution for an arbitrary function is immediately available by expressing the original function
as a Fourier series and then plugging in the solution for each sinusoidal component. In some
special cases where the Fourier series can be summed in closed form, this technique can even
yield analytic solutions.
Using the method for a generalized Fourier series, the usual Fourier series involving sines and
cosines is obtained by taking f1(x)=cosx and f2(x)=sinx . Since these functions form a complete
orthogonal system over [-π, π], the Fourier series of a function f(x) is given by

and n=1, 2, 3, .... Note that the coefficient of the constant term a0 has been written in a special
form compared to the general form for a generalized Fourier series in order to preserve
symmetry with the definitions of an and bn.
CODE:

import numpy as np
import matplotlib.pyplot as plt

28
# User Inputs
start_time = float(input("Enter the start time: "))
end_time = float(input("Enter the end time: "))
freq = float(input("Enter the frequency for the sinusoidal signal: "))
num_terms = int(input("Enter the number of terms for Fourier series: "))
num_points = 400 # Default number of points for the time array

# Generate Time Array


t = np.linspace(start_time, end_time, num_points) # Generate the time array using linspace

# Fourier Series Representation


def fourier_series(t, num_terms, freq):
# Initialize the signal as a zero array
signal = np.zeros(len(t))

# Summing the Fourier series terms


for n in range(1, num_terms + 1):
# Formula for nth term of Fourier series (only sine terms)
term = (4 / (np.pi * n)) * np.sin(2 * np.pi * n * freq * t)
signal += term # Add each term to the signal

return signal

# Generate the Fourier series signal


fourier_signal = fourier_series(t, num_terms, freq)

# Plotting the Results


plt.figure(figsize=(12, 8))

# Plot the Fourier Series Signal


plt.plot(t, fourier_signal, label=f"Fourier Series with {num_terms} terms", color='b')
plt.title(f"Fourier Series Representation (Up to {num_terms} terms)")
plt.xlabel("Time")
plt.ylabel("Amplitude")
plt.legend()

# Show the plot


plt.tight_layout()
plt.show()

29
SAMPLE OUTPUT:

RESULT:

Signature of Faculty

Exp No:8 Date:

30
Fourier Transform and Analysis of Fourier Spectrum
AIM: To perform Fourier Transform and Analysis of Fourier Spectrum.

APPARATUS REQUIRED: 1. Computer


2. Python 3.13
THEORY:
Fourier Transform is a mathematical model which helps to transform the signals between two
different domains, such as transforming signal from frequency domain to time domain or vice
versa. Fourier transform has many applications in Engineering and Physics, such as signal
processing, RADAR, and so on. In this article, we are going to discuss the formula of Fourier
transform, properties, tables, Fourier cosine transform, Fourier sine transform with complete
explanations.
What is Fourier Transform?
The generalisation of the complex Fourier series is known as the Fourier transform. The term
“Fourier transform” can be used in the mathematical function, and it is also used in the
representation of the frequency domain. The Fourier transform helps to extend the Fourier series
to the non-periodic functions, which helps us to view any functions in terms of the sum of
simple sinusoids.
Fourier Transform Formula
As discussed above, the Fourier transform is considered to be a generalisation of the complex
Fourier series in the limit L→∞. Also, convert discrete A n to the continuous F(k)dk and let
n/L→k. Finally, convert the sum to an integral.
Thus, the Fourier transform of a function f(x) is given by:

Forward and Inverse Fourier Transform


From the Fourier transform formula, we can derive the forward and inverse Fourier transform.

is known as the forward Fourier transform or simply Fourier transform.

is known as the inverse Fourier transform.

31
Fourier Transform Properties
The following are the important properties of Fourier transform:
 Duality – If h(t) has a Fourier transform H(f), then the Fourier transform of H(t) is H(-f).
 Linear transform – Fourier transform is a linear transform. Let h(t) and g(t) be two Fourier
transforms, which are denoted by H(f) and G(f), respectively. In this case, we can easily
calculate the Fourier transform of the linear combination of g and h.
 Modulation property – According to the modulation property, a function is modulated by the
other function, if it is multiplied in time.

CODE:
import numpy as np
import matplotlib.pyplot as plt

# User Inputs
start_time = float(input("Enter the start time: "))
end_time = float(input("Enter the end time: "))
freq = float(input("Enter the frequency for the sinusoidal signal: "))
num_points = 400 # Default number of points for the time array

# Generate Time Array


t = np.linspace(start_time, end_time, num_points) # Generate the time array using linspace

# Define the signal (sinusoidal signal in this case)


signal = np.sin(2 * np.pi * freq * t) # Sinusoidal signal of given frequency

# Compute the Fourier Transform of the signal


fft_signal = np.fft.fft(signal) # Apply FFT (Fast Fourier Transform) to the signal
frequencies = np.fft.fftfreq(num_points, t[1] - t[0]) # Get corresponding frequency bins

# Only keep the positive frequencies for plotting (real-world signals are symmetric)
positive_freqs = frequencies[:num_points // 2]
positive_fft = np.abs(fft_signal[:num_points // 2])

# Plotting the Results


plt.figure(figsize=(12, 8))

# Plot the original time-domain signal


plt.subplot(2, 1, 1)
plt.plot(t, signal, label="Time-Domain Signal", color='b')
plt.title("Time-Domain Signal")
plt.xlabel("Time (seconds)")
plt.ylabel("Amplitude")
plt.legend()

# Plot the frequency spectrum (magnitude of the Fourier Transform)


plt.subplot(2, 1, 2)
plt.plot(positive_freqs, positive_fft, label="Frequency Spectrum", color='r')
plt.title("Fourier Transform - Frequency Spectrum")

32
plt.xlabel("Frequency (Hz)")
plt.ylabel("Magnitude")
plt.legend()

# Show the plots


plt.tight_layout()
plt.show()

SAMPLE OUTPUT:

RESULT:

Signature of Faculty

Exp No:9 Date:


33
Laplace transforms
AIM: To perform Laplace Transform of signal.

APPARATUS REQUIRED: 1. Computer


2. Python 3.13
THEORY:

CODE:
import numpy as np
import matplotlib.pyplot as plt
from sympy import symbols, sin, laplace_transform, Heaviside
from sympy.abc import t, s

# User Inputs
start_time = float(input("Enter the start time: "))
end_time = float(input("Enter the end time: "))
freq = float(input("Enter the frequency for the sinusoidal signal: "))

# Define the time-domain signal (Unit step function multiplied by a sinusoidal signal)
u = Heaviside(t) # Unit step function
signal = u * sin(2 * np.pi * freq * t) # Sinusoidal signal multiplied by unit step (use sympy.sin)

# Laplace Transform
laplace_signal, _, _ = laplace_transform(signal, t, s) # Calculate the Laplace transform of the signal

# Display the Laplace Transform formula


print(f"The Laplace Transform of the signal is: {laplace_signal}")

# To visualize the response of the Laplace Transform (use a numerical approach)


# We plot the magnitude of the Laplace Transform for a range of s values.

# Generate an array of 's' values


s_values = np.linspace(0.01, 10, 500) # Avoid zero value in the denominator

# Define a function to calculate the magnitude of the Laplace Transform


laplace_magnitude = np.abs(np.array([laplace_signal.subs(s, s_val) for s_val in s_values]))

# Plotting the magnitude of the Laplace Transform


plt.figure(figsize=(10, 6))
plt.plot(s_values, laplace_magnitude, label="Magnitude of Laplace Transform", color='g')
plt.title("Laplace Transform - Magnitude")
plt.xlabel("s (complex frequency)")
plt.ylabel("Magnitude")
plt.legend()
plt.grid(True)

# Display the plot


plt.show()

34
SAMPLE OUTPUT:

RESULT:

Signature of Faculty

35
Exp No:10 Date:

Z transform
AIM: To perform Z-Transform of signal.

APPARATUS REQUIRED: 1. Computer


2. Python 3.13
THEORY:
The Z-transform (ZT) is a mathematical tool which is used to convert the difference equations
in time domain into the algebraic equations in z-domain. The Z-transform is a very useful tool
in the analysis of a linear shift invariant (LSI) system. An LSI discrete time system is
represented by difference equations. To solve these difference equations which are in time
domain, they are converted first into algebraic equations in z-domain using the Z-transform,
then the algebraic equations are manipulated in z-domain and the result obtained is converted
back into time domain using the inverse Z-transform.The Z-transform may be of two types viz.
unilateral (or one-sided) and bilateral (or two-sided).
Mathematically, if x(n) is a discrete-time signal or sequence, then its bilateral or two-sided Z-
transform is defined as –

Where z is a complex variable and it is given by,

Where r is the radius of a circle.


Also, the unilateral or one sided z-transform is defined as

Advantages and Disadvantages of Z-Transform


Following are the advantages of the Z-transform −
 The Z-transform makes the analysis of a discrete-time system easier by converting the
difference equations describing the system into simple linear algebraic equations.
 The convolution operation in time domain is converted into multiplication in z-domain.
 The Z-transform exists for the signals for which the discrete-time Fourier transform
(DTFT) does not exist.
Limitations – The primary limitation of the Z-transform is that using Z-transform, the frequency
36
domain response cannot be obtained and cannot be plotted.

CODE:
import numpy as np
import matplotlib.pyplot as plt

# User Inputs
start_time = float(input("Enter the start time: "))
end_time = float(input("Enter the end time: "))
freq = float(input("Enter the frequency for the sinusoidal signal: "))

# Discrete time range from start_time to end_time


n_values = np.arange(start_time, end_time, 0.01) # Discrete time steps

# Define the sinusoidal signal multiplied by the unit step


signal = np.sin(2 * np.pi * freq * n_values) * (n_values >= 0) # Sinusoidal signal * unit step

# Z-Transform numerical calculation


z_values = np.linspace(0.01, 10, 500) # Values of z (complex frequency) for plotting
magnitude_values = []

# Loop to calculate the magnitude of the Z-Transform for each z value


for z in z_values:
z_transform_value = np.sum(signal * np.power(z, -n_values)) # Z-transform formula
magnitude_values.append(abs(z_transform_value)) # Take magnitude of each result

# Plotting the magnitude of the Z-Transform


plt.figure(figsize=(10, 6))
plt.plot(z_values, magnitude_values, label="Magnitude of Z-Transform", color='r')
plt.title("Magnitude of Z-Transform of Sinusoidal Signal")
plt.xlabel("z (Complex frequency)")
plt.ylabel("Magnitude")
plt.legend()
plt.grid(True)

# Show the plot


plt.show()

37
SAMPLE OUTPUT:

RESULT:

Signature of Faculty

38

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