0

I have a continuous signal which I want to convert to a step-like function (I'm not sure what the correct term is)

So every sample in the lower part of the signal should be replaced by 1, middle ones 2 and high ones 3. And I want to control the size of steps (which is 3 in this example, but it can change)

How can I do that with MATLAB? Thanks in advance.

P.S.

I tried quant and ordinal, but I couldn't make it.

4

3 回答 3

0

您可以使用 heaviside 函数的组合。我应该提到有时 H(x=0)=0.5。

x=linspace(-1,5);  % your signal to be quantized---- could be anything
y= a*heaviside(x-x1)  + b*heaviside(x-x2) + c;   
% a, b and c decide the heights of your quantization
%   x1 and x2 decide the levels

如果你想要第四级,只需使用以下

y= a*heaviside(x-x1)  + b*heaviside(x-x2) + c*heaviside(x-x3)  +e;

该函数在这里定义:http ://en.wikipedia.org/wiki/Heaviside_step_function

量化到 k 个级别

    fun=a
    for k=1:n
       fun = fun+ h(i)*heaviside(x-xi(k))
    end
    fun=fun/normalization   % normalization is a number to decide the level of your signal
于 2014-10-18T22:50:11.400 回答
0

你想要这样的东西吗?

x = randn(1000, 1); % your signal
y = zeros(size(x));
y(x < -1) = 1;
y(x >= -1 & x < 3) = 2;
y(x >= 3) = 3;

您可以获得quantile用于确定阈值的分位数。

于 2014-10-18T22:22:54.103 回答
0

我认为这不是您要问的,但它可能有一些有用的信息。

Matlab 定点工具箱可以处理量化(有限精度)数字和算术。键入“help fi”以查看如何声明具有特定字长、小数长度和符号的定点数。这对于二进制点缩放特别有用(二进制字中的每个位位置表示 2 的幂)。

您可能需要此工具箱的特殊许可证。

于 2014-10-19T02:51:29.010 回答