Complete the code to generate an ASK modulated signal.
import numpy as np bit = 1 carrier_freq = 5 sampling_rate = 100 time = np.linspace(0, 1, sampling_rate) carrier = np.sin(2 * np.pi * carrier_freq * time) ask_signal = carrier * [1]
The ASK signal is the carrier multiplied by the bit value (0 or 1).
Complete the code to generate an FSK modulated signal for bit 0 or 1.
import numpy as np bit = 0 freq0 = 5 freq1 = 10 sampling_rate = 100 time = np.linspace(0, 1, sampling_rate) freq = [1] fsk_signal = np.sin(2 * np.pi * freq * time)
FSK uses different frequencies for bit 0 and bit 1. We select freq0 if bit is 0, else freq1.
Fix the error in the PSK signal generation code by filling the blank.
import numpy as np bit = 1 carrier_freq = 5 sampling_rate = 100 time = np.linspace(0, 1, sampling_rate) phase = [1] psk_signal = np.sin(2 * np.pi * carrier_freq * time + phase)
PSK changes the phase by π when bit is 1, else phase is 0.
Fill both blanks to create a dictionary comprehension mapping bits to their ASK signals.
bits = [0, 1] carrier_freq = 5 sampling_rate = 100 import numpy as np time = np.linspace(0, 1, sampling_rate) ask_signals = {bit: np.sin(2 * np.pi * carrier_freq * time) * [1] for bit in bits if bit [2] 1}
The dictionary comprehension creates ASK signals for bits equal to 1 by multiplying the carrier by the bit value.
Fill all three blanks to create a dictionary comprehension mapping bits to their PSK signals with phase shifts.
bits = [0, 1] carrier_freq = 5 sampling_rate = 100 import numpy as np time = np.linspace(0, 1, sampling_rate) psk_signals = { [1]: np.sin(2 * np.pi * carrier_freq * time + [2]) for [3] in bits }
The dictionary comprehension maps each bit to a PSK signal with phase π if bit is 1, else 0.
