<jupyter_start><jupyter_text>Experiment 3: Amplitude Modulation (AM)<jupyter_code>import numpy as np
from numpy import cos, absolute
from numpy.fft import fft,fftshift
from math import pi
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>DSB-FC<jupyter_code>fs = 8000
fc = 100
Ac = 1
fm = 10
Am = 0.6
t = np.arange(0,1,1/fs)
M = Am*cos(2*pi*fm*t)
C = Ac*cos(2*pi*fc*t)
S_AM = (Ac+M)*cos(2*pi*fc*t)
plt.plot(t,M)
plt.xlabel('Time (s)')
plt.ylabel('m(t)')
plt.xlim((0,5/fm))
plt.title('Message Signal in Time Domain')
plt.show()
plt.plot(t,C)
plt.xlabel('Time (s)')
plt.ylabel('c(t)')
plt.xlim((0,5/fm))
plt.title('Carrier Signal in Time Domain')
plt.show()
plt.plot(t,S_AM)
plt.xlabel('Time (s)')
plt.ylabel('S_{AM}(t)')
plt.xlim((0,5/fm))
plt.title('DSB+C Signal in Time Domain')
plt.show()
M_f = fftshift(absolute(fft(M)))
f = np.linspace(-fs/2, fs/2, len(M_f))
plt.stem(f, M_f/M_f.max())
plt.xlabel('Frequency (Hz)')
plt.ylabel('Normalized |M(f)|')
plt.xlim((-120,120))
plt.title('Spectrum of Message Signal')
plt.show()
C_f = fftshift(absolute(fft(C)))
plt.stem(f, C_f/C_f.max())
plt.xlabel('Frequency (Hz)')
plt.ylabel('Normalized |C(f)|')
plt.xlim((-120,120))
plt.title('Spectrum of Carrier Signal')
plt.show()
S_AM_f = fftshift(absolute(fft(S_AM)))
plt.stem(f, S_AM_f/S_AM_f.max())
plt.xlabel('Frequency (Hz)')
plt.ylabel('Normalized |S_{AM}(f)|')
plt.xlim((-120,120))
plt.title('Spectrum of DSB+C Signal')
plt.show()<jupyter_output>/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:1: UserWarning: In Matplotlib 3.3 individual lines on a stem plot will be added as a LineCollection instead of individual lines. This significantly improves the performance of a stem plot. To remove this warning and switch to the new behaviour, set the "use_line_collection" keyword argument to True.
  """Entry point for launching an IPython kernel.<jupyter_text>DSB-FC<jupyter_code>fs = 8000
fc = 100
Ac = 1
fm = 10
Am = 1
t = np.arange(0,1,1/fs)
M = Am*cos(2*pi*fm*t)
C = Ac*cos(2*pi*fc*t)
S_AM = M*C
plt.plot(t,M)
plt.xlabel('Time (s)')
plt.ylabel('m(t)')
plt.xlim((0,5/fm))
plt.title('Message Signal in Time Domain')
plt.plot(t,C)
plt.xlabel('Time (s)')
plt.ylabel('c(t)')
plt.xlim((0,5/fm))
plt.title('Carrier Signal in Time Domain')
plt.plot(t,S_AM)
plt.xlabel('Time (s)')
plt.ylabel('S_{AM}(t)')
plt.xlim((0,5/fm))
plt.title('DSB-SC Signal in Time Domain')
M_f = fftshift(absolute(fft(M)))
f = np.linspace(-fs/2, fs/2, len(M_f))
plt.stem(f, M_f/M_f.max())
plt.xlabel('Frequency (Hz)')
plt.ylabel('Normalized |M(f)|')
plt.xlim((-120,120))
plt.title('Spectrum of Message Signal')
plt.show()
C_f = fftshift(absolute(fft(C)))
plt.stem(f, C_f/C_f.max())
plt.xlabel('Frequency (Hz)')
plt.ylabel('Normalized |C(f)|')
plt.xlim((-120,120))
plt.title('Spectrum of Carrier Signal')
plt.show()
S_AM_f = fftshift(absolute(fft(S_AM)))
plt.stem(f, S_AM_f/S_AM_f.max())
plt.xlabel('Frequency (Hz)')
plt.ylabel('Normalized |S_{AM}(f)|')
plt.xlim((-120,120))
plt.title('Spectrum of DSB+C Signal')
plt.show()<jupyter_output>/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:1: UserWarning: In Matplotlib 3.3 individual lines on a stem plot will be added as a LineCollection instead of individual lines. This significantly improves the performance of a stem plot. To remove this warning and switch to the new behaviour, set the "use_line_collection" keyword argument to True.
  """Entry point for launching an IPython kernel.
{'fraction_non_alphanumeric': 0.18585097129602784, 'fraction_numerical': 0.028124093940272543, 'mean_word_length': 6.0552147239263805, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '553087', 'license': 'MIT', 'n_tokens_mistral': 1602, 'n_tokens_neox': 1442, 'n_words': 320, 'path': 'Experiment3.ipynb', 'repo_name': 'suhailnajeeb/ete-ice-399', 'size': '3449'}