fi.sum increases bitlength although fimath is set to KeepMSB
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Walter Roberson
2015년 7월 1일
You did not specify SumWordLength in your fimath() object.
댓글 수: 2
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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Fixed-Point Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!