Complete the code to define an analog signal as a continuous sine wave.
import numpy as np import matplotlib.pyplot as plt time = np.linspace(0, 1, 500) frequency = 5 analog_signal = np.sin(2 * np.pi * frequency * [1]) plt.plot(time, analog_signal) plt.title('Analog Signal') plt.show()
The analog signal is a sine wave that varies continuously with time.
Complete the code to create a digital signal by sampling the analog signal.
sample_rate = 50 sample_points = np.arange(0, 1, 1/[1]) digital_signal = np.sin(2 * np.pi * frequency * sample_points) plt.stem(sample_points, digital_signal) plt.title('Digital Signal') plt.show()
The digital signal samples the analog signal at intervals defined by the sample_rate.
Fix the error in the code to correctly quantize the digital signal into discrete levels.
quantization_levels = 8 quantized_signal = np.round(digital_signal * ([1] - 1)) / (quantization_levels - 1) plt.stem(sample_points, quantized_signal) plt.title('Quantized Digital Signal') plt.show()
The signal is scaled by the number of quantization_levels minus one to map values correctly.
Fill both blanks to create a dictionary mapping signal types to their characteristics.
signal_characteristics = {
'Analog': '[1]',
'Digital': '[2]'
}Analog signals have continuous waveform, while digital signals have discrete levels.
Fill all three blanks to complete the code that compares analog and digital signals in a DataFrame.
import pandas as pd signals = pd.DataFrame({ 'Type': ['Analog', 'Digital'], 'Representation': ['[1]', '[2]'], 'Precision': ['[3]', 'Finite'] }) print(signals)
Analog signals have continuous waveform and infinite precision. Digital signals use binary code and have finite precision.
