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 晨起四点开简书,是将零诗复制出。 五点二十便打住,...