美文网首页
2023-07-28

2023-07-28

作者: 芜青子 | 来源:发表于2023-07-28 05:17 被阅读0次
import numpy as np
import matplotlib.pyplot as plt

# Define the magnitudes and frequencies of the sinusoids
A1 = 1
A2 = 1
freq1 = 500  # Hz
freq2 = 3250  # Hz

# Define the sampling rate and sampling period
sampling_rate = 2000  # Hz
T = 1 / sampling_rate

# Define the time range for plotting the discrete-time signal x[n]
n = np.arange(0, 100)  # We'll consider 100 samples

# Calculate the discrete-time signal x[n]
x_n = A1 * np.cos(2 * np.pi * freq1 * n * T) + A2 * np.cos(2 * np.pi * freq2 * n * T)

# Define the impulse response h[n]
# The impulse response h[n] is a band-limited function that is 1 when |n| <= N and 0 otherwise.
N = int(np.pi / (2 * np.pi * T))  # N = π / (2π/T) = π / (2π * 1/2000) = 1000 samples
h_n = np.zeros_like(n)
h_n[:N+1] = 1

# Convolve x[n] with h[n] to get the output sequence y[n]
y_n = np.convolve(x_n, h_n)[:len(n)]

# Plot the output sequence y[n]
plt.stem(n, y_n, use_line_collection=True)
plt.xlabel('n')
plt.ylabel('y[n]')
plt.title('Output Sequence y[n] of the LTI System')
plt.grid()
plt.show()

相关文章

  • 2023-07-28

    我现在的痛苦来自于自己的知行不一,刚来的时候想的是没有复杂的人际关系,这个夏天不受罪,吹着空调,舒舒服服的过日子。...

网友评论

      本文标题:2023-07-28

      本文链接:https://www.haomeiwen.com/subject/zymrpdtx.html