sum
fi 配列要素の和
説明
例
fi ベクトルを作成し、コンストラクター内で fimath プロパティを指定します。
A = fi([1 2 5 8 5], 'SumMode', 'KeepLSB', 'SumWordLength', 32)
A =
1 2 5 8 5
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 11
RoundingMethod: Nearest
OverflowAction: Saturate
ProductMode: FullPrecision
SumMode: KeepLSB
SumWordLength: 32
CastBeforeSum: true
A の要素の合計を計算します。
S = sum(A)
S =
21
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 32
FractionLength: 11
RoundingMethod: Nearest
OverflowAction: Saturate
ProductMode: FullPrecision
SumMode: KeepLSB
SumWordLength: 32
CastBeforeSum: true
出力 S は SumWordLength が 32 に指定されたスカラーです。SumMode は KeepLSB に設定されていたため、S の FractionLength は 11 です。
fi 配列を作成し、各列の要素の和を計算します。
A=fi([1 2 8;3 7 0;1 2 2])
A =
1 2 8
3 7 0
1 2 2
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 11
S=sum(A)
S =
5 11 10
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 18
FractionLength: 11
MATLAB® は A の各列の和を含む行ベクトルを返します。ceil(log2(size(A,1)))=2 であるため、S の WordLength は 2 ビット増加します。SumMode の既定の設定が FullPrecision であるため、FractionLength は変化しません。
3 行 3 列の行列 A の 2 番目の次元 (dim=2) に沿って和を計算します。
A=fi([1 2 8;3 7 0;1 2 2])
A =
1 2 8
3 7 0
1 2 2
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 11
S=sum(A, 2)
S =
11
10
5
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 18
FractionLength: 11
MATLAB® は各行の要素の和からなる列ベクトルを返します。ceil(log2(size(A,2)))=2 であるため、S の WordLength は 18 です。
A の列の和を計算し、出力配列 S が同じデータ型をもつようにします。
A = fi([1 2 8;3 7 0;1 2 2])
A =
1 2 8
3 7 0
1 2 2
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 11
class(A)
ans = 'embedded.fi'
S = sum(A, 'native')S =
5 11 10
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 18
FractionLength: 11
class(S)
ans = 'embedded.fi'
MATLAB® は A のデータ型を維持し、タイプが embedded.fi の S の行ベクトルを返します。
入力引数
fi 入力配列。スカラー、ベクトル、行列または多次元配列として指定します。
データ型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
複素数のサポート: あり
正の整数スカラーとして指定された、動作する対象の次元。dim は fi オブジェクトにすることもできます。値を指定しない場合、既定は、サイズが 1 と異なる最初の配列の次元です。
データ型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
出力クラス。'double' または 'native' として指定します。出力クラスは演算と出力を行うデータ型を定義します。
typeが'double'の場合、sumは入力データ型にかかわらず、倍精度の配列を返します。typeが'native'の場合、sumは入力配列Aと同じクラスの配列を返します。
データ型: char
出力引数
和の配列。スカラー、ベクトル、行列または多次元配列として返されます。
メモ
和の計算には、fimath オブジェクトが使用されます。SumMode が FullPrecision、KeepLSB、または KeepMSB に設定されている場合、sum(A) に対する増加分の整数ビット数は ceil(log2(size(A,dim))) です。
制限
sumはデータ型がBooleanのfiオブジェクトはサポートしていません。
拡張機能
使用上の注意および制限:
可変サイズの入力は制御側
fimathオブジェクトのSumModeプロパティがSpecifyPrecisionまたはKeepLSBに設定されている場合のみサポートされます。
HDL コード生成
HDL Coder™ を使用して FPGA 設計および ASIC 設計のための VHDL、Verilog および SystemVerilog のコードを生成します。
バージョン履歴
R2006a より前に導入
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)