MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI Amaliy ish Topshirdi: ___-21guruh talabasi Urmanov Muxtorxo‘ja Qabul qildi: _________________ Toshkent 2024 21 y=cos(6π/x)+2sin(x3/π) 8 x ∈ (0; πN/8), ∆𝒙 = 𝟎. 𝟏𝟏 import numpy as np import matplotlib.pyplot as plt def signalni_kvantlash (signal, levels): # Signalning minimal va maksimal qiymatini topish min_signal = min(signal) max_signal = max(signal) # Kvantlash qadamini hisoblash qadam_ulchami = (max_signal - min_signal) / kvantlash_darajasi # Kvantlashni amalga oshirish kvantlangan_signal = [] for i in signal: # Eng yaqin kvantlash darajasini topish kvantlangan_qiymat = min_signal + round((i - min_signal) / qadam_ulchami) * qadam_ulchami kvantlangan_signal.append(kvantlangan_qiymat) return kvantlangan_signal # Signal hosil qilish N = 21 x = np.arange(0, np.pi*N/8, 0.11) analog_signal = np.cos(6*np.pi/x) + 2*np.sin(3*x/np.pi) kvantlash_darajasi = 6 kvantlangan_signal = signalni_kvantlash (analog_signal, kvantlash_darajasi) # Natijani chiqarish plt.figure(figsize=(15, 10)) plt.subplot(2, 2, 1) plt.plot(analog_signal, color = "red") plt.title("Analog signal") plt.xlabel('Vaqt') plt.ylabel('Signal qiymati') plt.grid(True) plt.subplot(2, 2, 2) plt.stem(analog_signal, 'y', markerfmt='.') plt.title("Diskret signal") plt.xlabel('Vaqt') plt.ylabel('Signal qiymati') plt.grid(True) plt.subplot(2, 2, 3) plt.plot(kvantlangan_signal, color = "blue", linestyle='--', marker='x') plt.title("Kvantlangan signal") plt.xlabel('Vaqt') plt.ylabel('Signal qiymati') plt.grid(True) plt.subplot(2, 2, 4) plt.step(x, analog_signal + 1, label='pre (default)') plt.plot(x, analog_signal + 1, 'C0o', alpha=0.5) plt.title("Kodlangan signal") plt.xlabel('Vaqt') plt.ylabel('Signal qiymati') plt.grid(True) plt.show()