End sem 7; week 2 winter session 2025
This commit is contained in:
BIN
7th-Semester-Fall-2024/ECOMMS/labs/lab2/Ecomms_Lab_2.pdf
Normal file
BIN
7th-Semester-Fall-2024/ECOMMS/labs/lab2/Ecomms_Lab_2.pdf
Normal file
Binary file not shown.
@ -2,7 +2,7 @@ import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import scipy as sp
|
||||
|
||||
def add_noise_snr_db(s, SNR):
|
||||
def add_noise(s, SNR):
|
||||
var_s = np.cov(s)
|
||||
var_noise = var_s/(10**(SNR/10))
|
||||
noise = var_noise**0.5 * np.random.randn(len(s))
|
||||
@ -51,14 +51,6 @@ def main():
|
||||
s_am = dsb_am(m, f_c, t)
|
||||
s_sc = dsb_sc(m, f_c, t)
|
||||
|
||||
plt.subplot(311)
|
||||
plt.plot(t, m, label="Message Signal")
|
||||
plt.subplot(312)
|
||||
plt.plot(t, s_am, label="DSB-AM Modulated Signal")
|
||||
plt.subplot(313)
|
||||
plt.plot(t, s_sc, label="DSB-SC Modulated Signal")
|
||||
plt.show()
|
||||
|
||||
m_am_demod = product_demod(s_am, f_m, f_c, f_s, t)
|
||||
m_sc_demod = product_demod(s_sc, f_m, f_c, f_s, t)
|
||||
|
||||
@ -66,14 +58,17 @@ def main():
|
||||
plt.plot(t, m_am_demod, label="Demodulated DSB-AM Signal")
|
||||
plt.plot(t, m_sc_demod, label="Demodulated DSB-SC Signal")
|
||||
plt.legend(loc="upper right")
|
||||
plt.savefig("demodulation-clean.png")
|
||||
plt.show()
|
||||
|
||||
m_am_noisy_demod = product_demod(add_noise_snr_db(s_am, 3), f_m, f_c, f_s, t)
|
||||
m_sc_noisy_demod = product_demod(add_noise_snr_db(s_sc, 3), f_m, f_c, f_s, t)
|
||||
|
||||
plt.plot(t, m)
|
||||
plt.plot(t, m_am_noisy_demod)
|
||||
plt.plot(t, m_sc_noisy_demod)
|
||||
plt.plot(t, m, label="Original Message Signal")
|
||||
plt.plot(t, m_am_noisy_demod, label="Demodulated DSB-AM Signal With Noise")
|
||||
plt.plot(t, m_sc_noisy_demod, label="Demodulated DSB-SC Signal With Noise")
|
||||
plt.legend(loc="upper right")
|
||||
plt.savefig("demodulation-noisy.png")
|
||||
plt.show()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
BIN
7th-Semester-Fall-2024/ECOMMS/labs/lab2/demodulation-clean.png
Normal file
BIN
7th-Semester-Fall-2024/ECOMMS/labs/lab2/demodulation-clean.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 71 KiB |
BIN
7th-Semester-Fall-2024/ECOMMS/labs/lab2/demodulation-noisy.png
Normal file
BIN
7th-Semester-Fall-2024/ECOMMS/labs/lab2/demodulation-noisy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 75 KiB |
Reference in New Issue
Block a user