0% found this document useful (0 votes)
15 views8 pages

DSPexp 1

The document outlines a program aimed at generating basic discrete time sequences, including unit step, impulse, ramp, exponential, sine, and cosine signals. It provides an algorithm for execution and includes a Python code implementation using NumPy and Matplotlib for plotting the generated signals. The program successfully generates and visualizes these elementary sequences.

Uploaded by

kdhanasankar7
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)
15 views8 pages

DSPexp 1

The document outlines a program aimed at generating basic discrete time sequences, including unit step, impulse, ramp, exponential, sine, and cosine signals. It provides an algorithm for execution and includes a Python code implementation using NumPy and Matplotlib for plotting the generated signals. The program successfully generates and visualizes these elementary sequences.

Uploaded by

kdhanasankar7
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
You are on page 1/ 8

Generation of basic signals

AIM :
To write a program to generate the elementary discrete time sequences.

ALGORITHM :
1. To start the program.
2. Generate the unit step ,unit impulse , unit ramp , exponential , sine wave form and cosine
wave form.
3. Execute the program.
4. Plot the output for each sequences.
5. Stop the program.

PROGRAM :
import numpy as np

import matplotlib.pyplot as plt

# Define discrete time axis

n = np.arange(-10, 11, 1) # Discrete time steps

# Unit Step Signal

unit_step = np.heaviside(n, 1)

# Impulse Signal (Discrete Kronecker Delta)

impulse = np.where(n == 0, 1, 0)

# Ramp Signal

ramp = np.where(n >= 0, n, 0)

# Sinusoidal Signal

sinusoidal = np.sin(0.5 * np.pi * n)

# Cosine Signal

cosine = np.cos(0.5 * np.pi * n)

# Exponential Signal
MATHEMATICAL EXPERSSION:
• Unit step signal
1 ; 𝑛≥0
u(t) = {
0; 𝑛 <0
• Impulse signal
1; 𝑛 =0
δ(n) = {
0; 𝑛 ≠0

• Ramp signal
𝑛; 𝑛≥0
r(n) = {
0; 𝑛 <0

• Sinusoidal signal
x(n) = sin (2𝜋𝑓n) For all n values

• Cosine signal
x(n) = cos (2𝜋fn) For all n values

• Exponential signal
x(n) = 𝑒 𝑛 For all ‘n’
exponential = np.exp(0.1 * n)

# Plotting

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

# Unit Step Plot

plt.subplot(3, 2, 1)

plt.stem(n, unit_step, 'b')

plt.title("Unit Step Signal (Discrete)")

plt.xlabel("Time index (n)")

plt.ylabel("Amplitude")

plt.grid()

# Impulse Plot

plt.subplot(3, 2, 2)

plt.stem(n, impulse, 'm')

plt.title("Impulse Signal (Discrete)")

plt.xlabel("Time index (n)")

plt.ylabel("Amplitude")

plt.grid()

# Ramp Plot

plt.subplot(3, 2, 3)

plt.stem(n, ramp, 'g')

plt.title("Ramp Signal (Discrete)")

plt.xlabel("Time index (n)")

plt.ylabel("Amplitude")

plt.grid()

# Sinusoidal Plot
FLOW CHART
plt.subplot(3, 2, 4)

plt.stem(n, sinusoidal, 'r')

plt.title("Sinusoidal Signal (Discrete)")

plt.xlabel("Time index (n)")

plt.ylabel("Amplitude")

plt.grid()

# Cosine Plot

plt.subplot(3, 2, 5)

plt.stem(n, cosine, 'y')

plt.title("Cosine Signal (Discrete)")

plt.xlabel("Time index (n)")

plt.ylabel("Amplitude")

plt.grid()

# Exponential Plot

plt.subplot(3, 2, 6)

plt.stem(n, exponential, 'c')

plt.title("Exponential Signal (Discrete)")

plt.xlabel("Time index (n)")

plt.ylabel("Amplitude")

plt.grid()

plt.tight_layout()

plt.show()
RESULT :

Thus the generation the elementary discrete time sequences is generated successfully.

You might also like