|
1-amaliy ish topshiriqlari
|
Sana | 18.05.2024 | Hajmi | 162,96 Kb. | | #242119 |
Bog'liq Signallar amaliy 1
O‘ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
Amaliy ish
Mavzu: 1-amaliy ish topshiriqlari: Davriy signallarni spektrlarini tadqiq etish
(diskretlash, kvantlash va kodlash)
Bajardi: Ne’matov Bahrom
Toshkent 2024
1-amaliy ish topshiriqlari: Davriy signallarni spektrlarini tadqiq etish
(diskretlash, kvantlash va kodlash)
12.
|
y=cos(xπ)+2sin(x)
|
8
|
x (0;1/4N),
|
import numpy as np
import matplotlib.pyplot as plt
# N talabaning jurnaldagi raqami
N = 8
# x intervali va diskretlash qadam
x = np.arange(0, 2 * N, 0.01)
# Signalning original qiymatlari
y = np.cos(x * np.pi) + 2 * np.sin(x)
# Diskretlash
x_discrete = np.arange(0, 2 * N, 0.06)
y_discrete = np.cos(x_discrete * np.pi) + 2 * np.sin(x_discrete)
# Kvantlash
m = 0.1 # Kvantlash qadami
y_quantized = np.round(y_discrete / m) * m
# Kodlash (binary)
def binary_code(val, m):
max_val = max(y_quantized)
num_levels = int((max_val / m) + 1)
return format(int(val / m), f'0{len(format(num_levels, "b"))}b')
y_encoded = [binary_code(val, m) for val in y_quantized]
# Grafika chizish
plt.figure(figsize=(14, 10))
plt.subplot(4, 1, 1)
plt.plot(x, y, label='Original Signal')
plt.title('Original Signal')
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
plt.subplot(4, 1, 2)
plt.stem(x_discrete, y_discrete, linefmt='r-', markerfmt='ro', basefmt='r-', use_line_collection=True, label='Discrete Signal')
plt.title('Discrete Signal')
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
plt.subplot(4, 1, 3)
plt.stem(x_discrete, y_quantized, linefmt='g-', markerfmt='go', basefmt='g-', use_line_collection=True, label='Quantized Signal')
plt.title('Quantized Signal')
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
plt.subplot(4, 1, 4)
# Kodlangan signalni raqamli qiymat sifatida ko'rsatish uchun
y_encoded_decimal = [int(b, 2) for b in y_encoded]
plt.stem(x_discrete, y_encoded_decimal, linefmt='b-', markerfmt='bo', basefmt='b-', use_line_collection=True, label='Encoded Signal')
plt.title('Encoded Signal')
plt.xlabel('x')
plt.ylabel('Binary Code (Decimal Representation)')
plt.legend()
plt.tight_layout()
plt.show()
Link:
https://colab.research.google.com/drive/1Jbkbj-xBLXsg2K_fHo7IYNo3hs0KgLS0
|
| |