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

Project Report on Basic Operations on Signals

The project report details basic operations on signals using Python programming, including time shifting, time reversal, amplitude scaling, and time scaling. It utilizes the Matplotlib library for visualization and provides source code examples for each operation. The report concludes with the advantages and applications of these signal processing techniques in various fields such as telecommunications and audio processing.

Uploaded by

mohanuppada6
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Project Report on Basic Operations on Signals

The project report details basic operations on signals using Python programming, including time shifting, time reversal, amplitude scaling, and time scaling. It utilizes the Matplotlib library for visualization and provides source code examples for each operation. The report concludes with the advantages and applications of these signal processing techniques in various fields such as telecommunications and audio processing.

Uploaded by

mohanuppada6
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Project report on Basic operations on signals-by

using python programming


Submitted by

GROUP VI
P.RAMANA(5221421068)
R.RITHIKA(522142176)
U. MOHAN(5221421091)
A.HEMANTH(522142101)
G.MYTHREYI(522142109)
P.GANESH(5221421125)
P.SHASI KUMAR(5221421129)
Mini project based on python programming

Write a program to perform basic operations on signals like Time shifting,


Time reversal, amplitude scaling, time scaling of signals.

Title: To perform basic operations on signals like Time shifting, Time reversal,
amplitude scaling, time scaling of signals.
SOFTWARE USED: Matplotlib: Visualization with Python:
- Matplotlib is a comprehensive library for creating static, animated, and
interactive visualizations in Python. Matplotlib makes easy things easy and hard
things possible.
THEORY:
A signal is a form of communication or message that carries
information or instructions. It can be in the form of sound, light, or any other
type of wave that can be detected and interpreted by a receiver. Signals are used
in various fields such as telecommunications, electronics, and even in our
everyday lives.
 Time shifting of signal:
Time shifting, also known as time delay or time lag, is a fundamental
operation in signal processing where the entire signal is shifted or delayed in
time. There are two types of shifting.
1.Right shifting
2.Left shifting
 Right shifting of time signal:
A time right shift refers to “moving a signal along the time axis in
the rightward direction”. It involves delaying the signal or causing a shift
towards later instances in the time domain
Source code:
import NumPy as np
import matplotlib.pyplot as plt
from scipy import signal
def right_shift_square_wave(frequency, duration, sampling_rate, shift_amount):
time = np.linspace(1, duration, int(sampling_rate * duration), endpoint=False)
square_wave = signal.square(2 * np.pi * frequency * time)
shifted_time = time + shift_amount
shifted_square_wave = np.interp(shifted_time, time, square_wave, left=0, right=1)
return time, square_wave, shifted_time, shifted_square_wave
frequency = 1.0 # Frequency of the square
waveduration = 5.0 # Duration of the signal
sampling_rate = 1000 # Sampling rate in Hz
shift_amount = 0.5 # Right shift amount
time, square_wave, shifted_time, shifted_square_wave = right_shift_square_wave(frequency,
duration, sampling_rate, shift_amount)
# Plot the original and shifted square wave signals
plt.figure(figsize=(10,4))
plt.subplot(2, 1, 1)
plt.plot(time, square_wave)
plt.title('Original SquarewaveSignal’)
plt.xlabel('Time’)t
plt.ylabel('Amplitude’)
plt.subplot(2, 1, 2)
plt.plot(shifted_time, shifted_square_wave)
plt.title(f'Shifted Square Wave Signal (Right Shift by {shift_amount} seconds)’)
plt.xlabel('Time’)
plt.ylabel('Amplitude’)
plt.tight_layout()
plt.show()
output wave forms:

 Left shifting of time signal:


Left shift refers to “moving a signal along the time axis in the
leftward direction”. Essentially, it involves bringing the signal earlier in time or
causing a shift towards earlier instances. For instance, in a time series or signal,
if you shift the entire waveform to the left by a certain amount of time, it means
the signal is being advanced or occurring earlier in the time domain
Source code:
import NumPy as np
import matplotlib.pyplot as plt
from scipy import signal
def right_shift_square_wave(frequency, duration, sampling_rate, shift_amount):
time = np.linspace(1, duration, int(sampling_rate * duration), endpoint=False)
square_wave = signal.square(2 * np.pi * frequency * time)
shifted_time = time - shift_amount
shifted_square_wave = np.interp(shifted_time, time, square_wave, left=-1, right=0)
return time, square_wave, shifted_time, shifted_square_wave
frequency = 1.0 # Frequency of the square wave
duration = 5.0 # Duration of the signal
sampling_rate = 1000 # Sampling rate in Hz
shift_amount = 0.5 # Right shift amount
time, square_wave, shifted_time, shifted_square_wave =right_shift_square_wave( frequency,
duration, sampling_rate, shift_amount)
# Plot the original and shifted square wave signals
plt.figure(figsize=(10, 4))
plt.subplot(2, 1, 1)
plt.plot(time, square_wave)
plt.title('Original SquareWaveSignal’)
plt.xlabel('Time’)
plt.ylabel('Amplitude’)
plt.subplot(2, 1, 2)
plt.plot(shifted_time, shifted_square_wave)
plt.title(f'Shifted Square Wave Signal (left Shift by {shift_amount} seconds)’)
plt.xlabel('Time’)
plt.ylabel('Amplitude’)
plt.tight_layout()
plt.show()

output waveforms:
 Time reversal of a signal
Time reversal of a signal involves flipping the signal in time,
essentially reversing the order of its values. It is also called as time folding of a
signal x(t) can be obtained by folding the signal about t=0.
Source code:
import numpy as np
import matplotlib.pyplot as plt
# Generating a sine wave
time = np.arange(0, 2 * np.pi, 0.1)
amplitude = np.sin(time)
# Reversing the signal
reversed_amplitude = np.flip(amplitude)
# Plotting the original and reversed signal
splt.figure(figsize=(10, 4))
plt.subplot(1, 2, 1)
plt.plot(time, amplitude)
plt.title('Original Signal’)
plt.subplot(1, 2, 2)
plt.plot(time, reversed_amplitude)
plt.title('Reversed Signal’)
plt.tight_layout()
plt.show()

output waveforms:
 Amplitude scaling of a signal:
Amplitude scaling of a signal refers to the process of changing
the magnitude of the signal without altering its shape or other characteristics.
This can be achieved by multiplying the signal by a constant factor. Amplitude
scaling involves multiplying the entire signal by a constant factor, often denoted
as A: y(t)=A⋅x(t), where y(t) is the scaled signal and x(t) is the original signal.
Source code:
import NumPy as np
import matplotlib.pyplot as plt
def amplitude_scaling(signal, scale_factor):
scaled_signal = signal * scale_factor
return scaled_signal
# Generate a sample signal (e.g., a sine wave)
time = np.linspace(0, 1, 1000, endpoint=False) # 1 second, 1000 samples
frequency = 5 # 5 Hz
amplitude = 1
# Define the scaling factor
scale_factor = 2.0
# Scale the signal
scaled_signal = amplitude_scaling(signal, scale_factor)
# Plot the original and scaled signals
plt.figure(figsize=(10, 6))
plt.plot(time, signal, label='Original Signal’)
plt.plot(time, scaled_signal, label=f'Scaled Signal (x {scale_factor})', linestyle='dashed’)
plt.title('Amplitude Scaling of a Signal’)
plt.xlabel('Time’)
plt.ylabel('Amplitude’)
plt.legend()
plt.grid(True)
plt.show()
output wave forms:

 Time scaling of a signal


The process of multiplying a constant to the time axis of a signal
is known as time scaling of the signal. The time scaling of signal may be time
compression or time expansion depending upon the value of the constant or

scaling factor. Mathematically, it is given by,𝑥(𝑡) → 𝑦(𝑡) = 𝑥(𝛼𝑡)Where, α is


a constant, called the scaling factor.

Source code:
import numpy as np
import matplotlib.pyplot as plt
def original_signal(t):
# Define the original signal function here.
# Example: x(t) = sin(2 * pi * t)
return np.sin(2 * np.pi * t)
def time_scaling(t, a):
# Perform time scaling: y(t) = x(a * t)
return original_signal(a * t)
def main():
# Generate time values
t = np.linspace(0, 1, 1000)
# Scaling factor
scaling_factor = 2 # You can adjust this value
# Original signal
x = original_signal(t)
Scaled signal
y=time_scaling(t,scaling_factor)
# Original signal
x = original_signal(t)
# Scaled signal
y = time_scaling(t, scaling_factor
# Plot the original and scaled signals
plt.figure(figsize=(10, 5))
plt.plot(t, x, label='Original Signal')
plt.plot(t, y, label=f'Scaled Signal (a = {scaling_factor})’)
plt.title('Time Scaling of a Signal')
plt.xlabel('Time')
plt.ylabel('Amplitude')
plt.legend()
plt.grid(True)
plt.show()
if _name_ == "_main_":
main()
output waveforms:

PRECAUTIONS:
1. Program must be written carefully to avoid errors.

2. Program should be saved before executing the code.

3. Check the errors before running the program.

Advantages:
1.Time shifting allows you to delay or advance a signal in time. This can be useful for
aligning signals in a system, synchronizing events, or adjusting the timing of a signal to
match specific requirements without altering the signal's shape or amplitude.
2. Time reversal can be useful for certain applications such as signal processing and analysis.
It allows you to examine how a signal behaves when time is reversed.
3. Amplitude scaling allows you to adjust the magnitude of a signal. This is useful for
controlling the strength or intensity of a signal without affecting its timing.
4. Time scaling is beneficial for adjusting the duration of a signal without changing its shape.
It helps in compressing or expanding the signal in the time domain.
Applications:
1.In communication systems, time shifting can be used to align received signals with
transmitted signals for proper demodulation.
2. In seismic signal processing, time reversal techniques can be applied to focus signals at a
specific point, improving the quality of seismic imaging.
3. In audio processing, amplitude scaling can be used to control the volume of a sound signal
without distorting its waveform
4. In video processing, time scaling can be used to speed up or slow down the playback of a
video without affecting the content's visual appearance.

Conclusion:
Each of these operations provides flexibility in manipulating signals to suit specific
requirements in fields such as telecommunications, audio processing, image processing,
control systems, and more. They enable modification, analysis, and enhancement of signals in
numerous practical applications.

You might also like