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 晨起四點開簡書,是將零詩復制出。 五點二十便打住,...