如何从给定的量化信号中去除量化噪声?

2024-04-18 12:52:19 发布

您现在位置:Python中文网/ 问答频道 /正文

比如说,我有一个模拟信号,它是离散表示:

enter image description here

import numpy as np
import pylab as py

def sin(frequency = 1, time = 1, sampling = 128, phi = 0):
    '''
    Sinus function for a given frequency in Hz, length in time,
    sampling frequency, and phase.
    '''
    dt = 1.0 / sampling
    t = np.arange(0, time, dt)
    s = np.sin((2 * np.pi * frequency * t) + phi)
    return s, t

s_analog_1, t_analog_1 = sin(frequency = 1, sampling = 1000)
py.plot(t_analog_1, s_analog_1, linewidth = '1.5', color = 'red', 
label = 'analog signal')

s_analog_2, t_analog_2 = sin(frequency = 1, sampling = 10)
py.plot(t_analog_2, s_analog_2, 'o', color = 'red')

# Calculate the quantization noise, ie "R/2^N"
s_discrete, t_discrete = sin(frequency = 1, sampling = 10)
N = 3
R = 2
dy = R/2**N
s_quantized = np.floor(s_discrete / dy) * dy + 0.5 *dy

py.plot(t_discrete, s_quantized, color = 'gray', label = 'discrete signal')
py.plot(t_discrete, s_quantized, 'o', color = 'gray')

py.legend(loc='upper right', fontsize='10')

py.show()

模数转换器为3位电平,测量范围为2。如何从离散信号表示中去除量化噪声,使其适合模拟信号表示?这个问题是在我已经收集到离散信号的情况下提出的。在去除过程中,我可以使用量化噪声系数,即dy = R/2^N。提前谢谢你。在


Tags: pyimporttimeplotasnpsincolor