quantdecode (MathScript RT Module Function)

LabVIEW 2012 MathScript RT模块帮助

版本日期:June 2012



Owning Class: filter implementation

Requires: MathScript RT Module


y = quantdecode(x, n)

y = quantdecode(x, n, r)

y = quantdecode(x, n, r, s)

Legacy Name: udecode


Decodes quantized integer inputs to floating-point outputs.




Name Description
x Specifies the integers to decode. If the elements of x are signed integers, all elements of x must fall in the range [-2^(n-1), 2^(n-1)-1]. Otherwise, all elements of x must fall in the range [0, 2^n-1].
n Specifies the level of quantization. n is a positive integer between 2 and 32.
r Specifies the output range. r is a positive number. The default is 1.
s Specifies how to treat the overflows. s accepts the following values.

'saturate' (default) LabVIEW saturates the elements of x that are outside of the range.
'wrap' LabVIEW wraps the elements according to modulo 2^n arithmetic.


Name Description
y Returns the decoded floating-point numbers.


quantdecode does not accept complex inputs. To encode and decode a complex x, use quantencode and quantdecode separately on the real and imaginary parts of x and then combine the results, as shown in the following example.

X = real(input)                        %get the real part of the input
Y = imag(input)                        %get the imaginary part of the input

X = quantencode(X, 4, 1, 'unsigned')   %encode X
Y = quantencode(Y, 4, 1, 'unsigned')   %encode Y

X = quantdecode(X, 4, 1, 'wrap')       %decode X
Y = quantdecode(Y, 4, 1, 'wrap')       %decode Y

output = complex(X, Y)                 %combine the real and imaginary parts

The following table lists the support characteristics of this function.

Supported in the LabVIEW Run-Time Engine Yes
Supported on RT targets Yes
Suitable for bounded execution times on RT Not characterized


X = -1:0.01:1;
Y = quantencode(X, 4, 1, 'signed');
X1 = quantdecode(Y, 4, 1);
plot(X, X1)

Related Topics