文档

量化

量化定点号

句法

y =量化(x)
y= quantize(x,nt)
y= quantize(x,nt,rm)
y =量化(x,nt,rm,oa)
YBP= quantize(x,s)
ybp =量化(x,s,wl)
ybp =量化(x,s,wl,fl)
ybp =量化(x,s,wl,fl,rm)
YBP= quantize(x,s,wl,fl,rm,oa)

Description

y= quantize(X量化Xusing these default values:

  • numerictype(True,16,15)

  • Floor舍入方法

  • 溢出动作

numerictype,舍入方法和溢流作用仅在量化过程中适用。最终值,量化y,没有任何fimath。

y= quantize(X,,,,nt量化X到指定的numerictypent。舍入方法和使用defa溢出的行动ult values.

y= quantize(X,,,,nt,,,,R M量化X到指定的numerictype,,,,nt和圆形方法,R M。溢出操作使用默认值。

例子

y= quantize(X,,,,nt,,,,R M,,,,oa量化X到指定的numerictype,,,,nt,舍入方法,R M和溢出动作,oa

YBP= quantize(X,,,,s量化Xto a binary-point, scaled fixed-point number. Thes输入指定要在numerictype(S,16,15)。Unspecified properties use these default values:

  • wordlength16

  • FractionLength15

  • 圆形的Floor

  • OverflowAction

YBP= quantize(X,,,,s,,,,WLuses the specified word length,WL。分数长度默认为WL–1。未指定的属性使用默认值。

YBP= quantize(X,,,,s,,,,WL,,,,佛罗里达州使用指定的分数长度,佛罗里达州。未指定的属性使用默认值。

YBP= quantize(X,,,,s,,,,WL,,,,佛罗里达州,,,,R Muses the specified rounding method,R M。未指定的属性使用默认值。

例子

YBP= quantize(X,,,,s,,,,WL,,,,佛罗里达州,,,,R M,,,,oauses the specified overflow action,oa

Examples

collapse all

Createnumerictype目的,,,,NTBP,指定签名的8位单词长度,4位分数长度数据类型。

ntbp = numerictype(1,8,4);

Define the input.

x_bp = fi(pi)
X_BP = 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13

Use the definednumerictype,,,,NTBP,,,,to quantize the input,X_BP,到二进制缩放数据类型。

ybp1 =量化(x_bp,ntbp)
YBP1 = 3.1250 DatatyPemode:固定点:二进制点缩放签名:签名wordlength:8 fractionLength:4

创建一个numerictype目的,,,,NTSB,,,,which specifies a slope-bias data type.

ntsb = numerictype('Scaling',,,,“ Slopebias”,,,,...'slopeadjustmentFactor',,,,1.8,'偏见',,,,...1,'FixedExponent',,,,-12);

Define the input.

x_bp = fi(pi)
X_BP = 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13

Use the definednumerictype,,,,NTSB,,,,to quantize the input,X_BP,,,,to a slope-bias data type.

ySB1 = quantize(x_BP, ntSB)
YSB1 = 3.1415 DatatyPemode:固定点:斜率和偏置缩放签名:签名WordLength:16斜率:0.000439453125偏差:1

创建一个numerictype目的,,,,NTBP,指定签名的8位单词长度,4位分数长度数据类型。

ntbp = numerictype(1,8,4);

Define the input.

X_SB = fi(rand(5,3),numerictype('Scaling',,,,“ Slopebias”,,,,'偏见',-0.125))
x_SB = 0.8147 0.0975 0.1576 0.8750 0.2785 0.8750 0.1270 0.5469 0.8750 0.8750 0.8750 0.4854 0.6324 0.8750 0.8003 DataTypeMode: Fixed-point: slope and bias scaling Signedness: Signed WordLength: 16 Slope: 3.0517578125e-5 Bias: -0.125

Use the definednumerictype,,,,NTBP,,,,to quantize the input,X_SB,到二进制点缩放数据类型。

ybp2 =量化(x_sb,ntbp,“最近”,,,,“饱和”
YBP2 = 0.8125 0.1250 0.1875 0.8750 0.2500 0.8750 0.1250 0.5625 0.8750 0.8750 0.8750 0.5000 0.6250 0.8750 0.8125 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 8 FractionLength: 4

创建一个numerictype目的,,,,NTSB,,,,which specifies a slope-bias data type.

ntsb = numerictype('Scaling',,,,“ Slopebias”,,,,...'slopeadjustmentFactor',,,,1.8,'偏见',,,,...1,'FixedExponent',,,,-12);

Define the input.

X_SB = fi(rand(5,3),numerictype('Scaling',,,,“ Slopebias”,,,,'偏见',-0.125))
x_SB = 0.8147 0.0975 0.1576 0.8750 0.2785 0.8750 0.1270 0.5469 0.8750 0.8750 0.8750 0.4854 0.6324 0.8750 0.8003 DataTypeMode: Fixed-point: slope and bias scaling Signedness: Signed WordLength: 16 Slope: 3.0517578125e-5 Bias: -0.125

Use the definednumerictype,,,,NTSB,,,,to quantize the input,X_SB,,,,to a slope-bias data type.

ysb2 =量化(x_sb,ntsb,'天花板',,,,'裹'
ySB2 = 0.8150 0.0978 0.1580 0.8752 0.2789 0.8752 0.1272 0.5469 0.8752 0.8752 0.8752 0.4854 0.6326 0.8752 0.8005 DataTypeMode: Fixed-point: slope and bias scaling Signedness: Signed WordLength: 16 Slope: 0.000439453125 Bias: 1

创建一个numerictype目的,,,,NTBP,指定签名的8位单词长度,4位分数长度数据类型。

ntbp = numerictype(1,8,4);

Define the input.

xint =int8(-16:4:16)
xint =1x9 int8行矢量-16 -12 -8 -4 0 4 8 12 16

Use the definednumerictype,,,,NTBP,,,,to quantize the input|xInt| to a binary point scaled data type.

YBP3 = quantize(xInt,ntBP,'Zero'
YBP3 = 0 4 -8 -4 0 4 -8 -4 0 DatatyPemode:固定点:二进制点缩放签名:签名wordlength:8 fractionLength:4

显示量化输出的范围。

range(yBP3)
ans = -8.0000 7.9375 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 8 FractionLength: 4

这first two and last three values are wrapped because they are outside the representable range of the output type.

创建一个numerictype目的NTSB,,,,which specifies a slope-bias data type.

ntsb = numerictype('Scaling',,,,“ Slopebias”,,,,...'slopeadjustmentFactor',,,,1.8,'偏见',,,,...1,'FixedExponent',,,,-12);

Define the input.

xint =int8(-16:4:16)
xint =1x9 int8行矢量-16 -12 -8 -4 0 4 8 12 16

Use the definednumerictype,,,,NTSB,,,,to quantize the input,Xint,,,,to a slope-bias data type.

ysb3 =量化(xint,ntsb,'圆形的',,,,“饱和”
ySB3 = Columns 1 through 7 -13.4000 -11.9814 -7.9877 -3.9939 -0.0002 3.9936 7.9873 Columns 8 through 9 11.9811 15.3996 DataTypeMode: Fixed-point: slope and bias scaling Signedness: Signed WordLength: 16 Slope: 0.000439453125 Bias: 1

显示量化输出的范围。

range(ySB3)
ans = -13.4000 15.3996 DataTypeMode: Fixed-point: slope and bias scaling Signedness: Signed WordLength: 16 Slope: 0.000439453125 Bias: 1

这first and last values saturate because they are at the limits of he representable range of the output type.

输入参数

collapse all

输入数据进行量化。有效输入是:

  • 内置签名或未签名的整数(int8,,,,int16,,,,int32,,,,INT64,,,,UINT8,,,,uint16,,,,UINT32,,,,Uint64

  • Binary point scaled fixed-point fi

  • Slope-bias scaled fixed-point fi

尽管FI双打和FI单打被允许作为输入,但它们通过量化function without being quantized.

数字型目的that defines the sign, word length, and fraction length of a fixed-point number.

舍入方法to use

当数据溢出发生时要采取的措施

是否签署了定点号(是否签署)(true)or unsigned (错误的

定点编号的单词长度

固定点的分数长度

输出参数

collapse all

Quantized value of the input

输入量化为二进制缩放值

扩展功能

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

也可以看看

|||

Introduced before R2006a

Was this topic helpful?