quantize
quantizer
オブジェクトを使用した数値データの量子化
説明
は、y
= quantize(q
,x
)quantizer
オブジェクト q
を使用して x
を量子化します。
x
が数値配列の場合、x
の各要素が量子化されます。出力y
は組み込みの double として返されます。x
が cell 配列の場合、cell 配列の各数値要素が量子化されます。出力y
のフィールドは組み込みの double として返されます。x
が構造体の場合、x
の各数値フィールドが量子化されます。出力y
のフィールドは組み込みの double として返されます。
quantize
では、x
の数値以外の要素やフィールドは変更されず、数値以外の値に対する警告も発行されません。
quantizer
オブジェクトの状態 max
、min
、noverflows
、nunderflows
、および noperations
は quantize
の呼び出し中に更新され、reset
が呼び出されるまで累計が維持されます。
例
カスタム精度の浮動小数点型にデータを量子化
quantize
を使用して、カスタム精度の浮動小数点型にデータを量子化します。
x = linspace(-15,15,1000); q = quantizer('float','floor',[6 3]); range(q)
ans = 1×2
-14 14
y = quantize(q,x);
Warning: 68 overflow(s) occurred in the fi quantize operation.
plot(x,y); title(tostring(q))
固定小数点型に量子化
quantize
を使用して、語長が 6 ビットで小数部の長さが 2 ビット、負方向に丸め、オーバーフロー時にラップする固定小数点型にデータを量子化します。
x = linspace(-15,15,1000); q = quantizer('fixed','floor','wrap',[6 2])
q = DataMode = fixed RoundMode = floor OverflowMode = wrap Format = [6 2]
range(q)
ans = 1×2
-8.0000 7.7500
y = quantize(q,x);
Warning: 468 overflow(s) occurred in the fi quantize operation.
plot(x,y); title(tostring(q))
quantize
を使用して、語長が 3 ビットで小数部の長さが 2 ビット、最も近い偶数方向に丸め、オーバーフロー時にラップする固定小数点型にデータを量子化します。
q = quantizer('fixed','convergent','wrap',[3 2]); x = (-2:eps(q)/4:2)'; y = quantize(q,x);
Warning: 33 overflow(s) occurred in the fi quantize operation.
plot(x,[x,y],'.-'); title(tostring(q)); axis square
入力引数
q
— 量子化に使用するデータ型プロパティ
quantizer
オブジェクト
量子化に使用するデータ型プロパティ。quantizer
オブジェクトとして指定します。
例: q = quantizer('fixed','ceil','saturate',[5 4]);
x
— 量子化するデータ
スカラー | ベクトル | 行列 | 多次元配列 | cell 配列 | 構造体
量子化するデータ。スカラー、ベクトル、行列、多次元配列、cell 配列、または構造体として指定します。
x
が数値配列の場合、x
の各要素が量子化されます。x
が cell 配列の場合、cell 配列の各数値要素が量子化されます。x
が構造体の場合、x
の各数値フィールドが量子化されます。
quantize
では、x
の数値以外の要素やフィールドは変更されず、数値以外の値に対する警告も発行されません。
データ型: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
| struct
| cell
複素数のサポート: あり
x1,x2,…
— 量子化するデータ (個別の要素)
スカラー | ベクトル | 行列 | 多次元配列 | cell 配列 | 構造体
量子化するデータ (個別の要素)。スカラー、ベクトル、行列、多次元配列、cell 配列、または構造体として指定します。
データ型: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
| struct
| cell
複素数のサポート: あり
出力引数
y
— 量子化されたデータ
スカラー | ベクトル | 行列 | 多次元配列 | cell 配列 | 構造体
量子化されたデータ。スカラー、ベクトル、行列、多次元配列、cell 配列、または構造体として返されます。
x
が数値配列の場合、出力y
は組み込みの double として返されます。x
が cell 配列の場合、出力y
のフィールドは組み込みの double として返されます。x
が構造体の場合、出力y
のフィールドは組み込みの double として返されます。
[y1,y2,…]
— 量子化されたデータ (個別の要素)
スカラー | ベクトル | 行列 | 多次元配列 | cell 配列 | 構造体
量子化されたデータ (個別の要素)。スカラー、ベクトル、行列、多次元配列、cell 配列、または構造体として返されます。
バージョン履歴
R2012b で導入R2021b: 関数 quantize
の丸め動作の変更
以前のリリースでは、quantize
は範囲
の値を無限大方向に丸め、範囲 realmax
< input < realmax + 0.5*eps
(realmax)-realmax > x > -realmax - 0.5*eps
の値を負の無限大方向に丸めていました。R2021b 以降では、使用する丸め手法に応じて、これらの範囲の値が次のように量子化されます。
丸め手法 | 範囲 realmax < input < realmax + 0.5*eps(realmax) の値の丸め方向 | 範囲 -realmax > x > -realmax - 0.5*eps の値の丸め方向 |
---|---|---|
floor | realmax (x < realmax + eps の場合) | -Inf |
ceil | Inf | -realmax (x > -realmax - eps の場合) |
round | realmax | -realmax |
convergent | realmax | -realmax |
fix | realmax (x < realmax + eps の場合) | -realmax (x > -realmax - eps の場合) |
nearest | realmax | -realmax |
参考
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)