1

我在我的课程材料中得到了这个问题的解决方案。

问题:

x(t)在处采样的信号10 sample/sec。考虑第10 samples一个x(t)

x(t) = 0.3 cos(2*pi*t);

使用 8 位量化器找到量化误差。

解决方案:

(256 quantisation levels)
t=1:10;
x=(0.3)*cos(2*pi*(t-1)/10);
mx=max(abs(x));
q256=mx*(1/128)*floor(128*(x/mx));
stem(q256)
e256=(1/10)*sum(abs(x-q256))
Error: e256 = 9.3750e-04

对此没有任何解释,您能详细解释一下这是如何计算的吗?

4

1 回答 1

0

对于我喜欢的前两行代码,

Fs = 10;
L = 10;
t = (0 : L - 1) / Fs;
x = 0.3 * cos(2 * pi * t);

其中Fs是采样频率、L样本数并t显示时间。

请注意,它x是频率为的正弦曲线,Fx = 1 Hz或者我们可以说它是周期性的Tx = 1 sec

对于8-bit量化,我们有256级别。由于L / Fs = [10 sample] / [10 sample/sec] = 1 sec等于Tx(整个周期x),我们可以使用正样本。

mx = max(abs(x));

mx is defined because in order to use floor we need to scale the x.

q256 = mx*(1/128)*floor(128*(x/mx));

mx shows the maximum value for x so x / mx will take values over [-1 1] and 128*x/mx over [-128 128] will cover all 256 levels.

So we will quantize it with floor and scale it back (mx*1/128).

e256 = (1/L)*sum(abs(x-q256))

e256 simply shows the mean error over 10 samples.

Note that if L / Fs < Tx then this quantization won't be the optimum one.

Have in mind

The answer that you are given has some problems!

suppose x = [-1 -.2 0 .7 1]; and we want to quantize it with 2 bits.

mx = max(abs(x));
q4 = mx * (1/2) * floor(2*(x/mx));

Will give q4 = [-1 -0.5 0 0.5 1] which has 5 levels (instead of 2^2 = 4).

这可能不是什么大问题,你可以删除关卡x=1并拥有q4 = [-1 -0.5 0 0.5 0.5],但代码仍然需要一些改进,当然错误会增加。

一个简单的解决方案是添加

[~,ind] = max(x);
x(ind) = x(ind) - 1e-10;

在定义mxso 的最大值之后,x将被量化到低一级。

误差将增加到0.0012

于 2014-12-01T18:06:41.457 回答