Value Exceeds while dividing

1 回表示 (過去 30 日間)
Pat
Pat 2012 年 11 月 26 日
I have 2 matrices
A ranges between -32768 to 32767 ,it is 100x1 matrix
class(A) is int16
B matrix ranges from -1473 to 1570,it is 100x1 matrix
class(B) is double
asuming i divide manually the values ,max(B)/max(A), i get correct answer , but while runnning in m file , the value exceeds
The maximum value must be .049 ,but i get 1.73,
I converted both A and B to double,still i get same error ,
please assist

採用された回答

Walter Roberson
Walter Roberson 2012 年 11 月 26 日
What happens if you break it up and display the values:
ma = max(A)
class(ma)
size(ma)
mb = max(B)
class(mb)
size(mb)
mb / ma
mb ./ ma
  9 件のコメント
Walter Roberson
Walter Roberson 2012 年 11 月 26 日
Any non-zero value divided by 0 gives an infinite result, which is going to be more than 5 bits.
If you have a 14 bit value divided by 1 (which is a valid 16 bit value) then you are going to get a 14 bit value output.
Any 14 bit value divided by a value that could be represented (without compression) in 8 or fewer binary digits, is going to give a result that requires more than 5 bits.
64 (7 bits) / 2 (2 bits) = 32 (6 bits) so the numbers represented as 14 bits can be pretty small and you would still have problems.
Pat
Pat 2012 年 11 月 26 日
Thanks walter

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by