フィルターのクリア

fi.sum increases bitlength although fimath is set to KeepMSB

2 ビュー (過去 30 日間)
Lennart
Lennart 2015 年 7 月 1 日
コメント済み: Walter Roberson 2015 年 7 月 2 日
Hi there,
I was wondering why the sum function increases the length of my fixed point variable.
Here is a little example:
fimath('SumMode','KeepMSB')
x = fi(1:100,true,8,0)
.
.
.
y = sum(x)
y = 5050
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 15
FractionLength: 0
I actually expected y to be 39, which is the decimal representation of 00100111 (the first 8 bit of y). It seams that the sum function just works with FullPrecision anyways?! Am I doing something wrong here?
Any help is highly appreciated.
Regards,
Len

採用された回答

Walter Roberson
Walter Roberson 2015 年 7 月 1 日
You did not specify SumWordLength in your fimath() object.
  2 件のコメント
Lennart
Lennart 2015 年 7 月 2 日
Allright thanks for that I sort of overread that I guess. Unfortunately it still does not work. Here is what I did:
rounding = 'nearest';
overflowAction = 'Saturate';
sumMode = 'KeepMSB';
productMode = 'KeepMSB';
wordLength = 8;
fimath('RoundingMethod', rounding, 'OverflowAction', overflowAction, 'SumMode', sumMode, 'SumWordLength', wordLength, 'ProductMode', productMode, 'ProductWordLength', wordLength );
but if I type fimath in the command window it returns the default (sumMode = FullPrecission etc) Am I assigning fimath wrong?
Regards,
Len
Walter Roberson
Walter Roberson 2015 年 7 月 2 日
I think you might need to assign the fimath object to a variable to get it to work, so that the object exists in the workspace. When you do not assign it, the object would get discarded at the end of the line.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by