SS LAB MANUAL_D23 FINAL
SS LAB MANUAL_D23 FINAL
Branch : ……………………………………………………….
Academic year……………………………..
………………………………………..
Signature of the Course Coordinator
INDEX
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
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:
The figure above shows the graphical representation of a discrete step function.
Unit Ramp Function
A discrete unit ramp function can be defined as
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
# 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:
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.
These operations are foundational in signal processing, enabling signal analysis, transformation,
and manipulation.
4
Code for Addition and subtraction
import numpy as np
# User Inputs
# Operations
# Plotting
plt.figure(figsize=(10, 5))
plt.subplot(1, 2, 1)
plt.title("Addition")
5
plt.xlabel("Time")
plt.ylabel("Amplitude")
plt.subplot(1, 2, 2)
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
# User Inputs
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.title("Addition of Signals")
plt.xlabel("Time")
plt.ylabel("Amplitude")
# Plot Subtraction
plt.subplot(2, 2, 2)
plt.title("Subtraction of Signals")
plt.xlabel("Time")
plt.ylabel("Amplitude")
# Plot Multiplication
plt.subplot(2, 2, 3)
plt.title("Multiplication of Signals")
plt.xlabel("Time")
plt.ylabel("Amplitude")
8
# Plot Division
plt.subplot(2, 2, 4)
plt.title("Division of Signals")
plt.xlabel("Time")
plt.ylabel("Amplitude")
# Adjust layout
plt.tight_layout()
plt.show()
Sample Output:
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
# 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:
AIM: To generate signals with defined energy, power, and even/odd characteristics.
2. Power Signals
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: "))
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'}")
Sample Output:
RESULT:
14
Signature of Faculty
division.
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
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
# 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
# Show plot
plt.tight_layout()
plt.show()
19
Sample Output:
RESULT:
Signature of Faculty
20
Exp No:5 Date:
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
# Perform Convolution
convolved_signal = np.convolve(sinusoidal_signal, pulse_signal, mode='same') #
Convolution of both signals
# 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
23
Sample Output:
RESULT:
Signature of Faculty
24
Exp No:6 Date:
Correlation
AIM: To perform correlation of signals
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
25
# Compute the Cross-Correlation between the Two Signals
correlation_signal = np.correlate(sinusoidal_signal, delayed_signal, mode='same') # Cross-correlation
# Adjust layout
plt.tight_layout()
plt.show()
26
SAMPLE OUTPUT:
RESULT:
Signature of Faculty
27
Fourier Series Representation
AIM: To represent a signal using Fourier series.
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
return signal
29
SAMPLE OUTPUT:
RESULT:
Signature of Faculty
30
Fourier Transform and Analysis of Fourier Spectrum
AIM: To perform Fourier Transform and Analysis of Fourier Spectrum.
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
# 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])
32
plt.xlabel("Frequency (Hz)")
plt.ylabel("Magnitude")
plt.legend()
SAMPLE OUTPUT:
RESULT:
Signature of Faculty
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
34
SAMPLE OUTPUT:
RESULT:
Signature of Faculty
35
Exp No:10 Date:
Z transform
AIM: To perform Z-Transform of signal.
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: "))
37
SAMPLE OUTPUT:
RESULT:
Signature of Faculty
38