フィルターのクリア

Floating number to Fixed Point conversion in MATLAB

5 ビュー (過去 30 日間)
Anubhav
Anubhav 2015 年 9 月 30 日
回答済み: Walter Roberson 2015 年 10 月 1 日
A decimal number, say, 8.125 can be represented in as a binary number ABCD.EFG= 1000.001 (8.125= (2^3)+(2^-3)). I want to know if MATLAB has a tool in coding or Simulink where I can input 8.125 and MATLAB tells me which of A, B, C, D, E, F, G will be 1. For example if I input 8.125, A=1, G=1 and rest all zeros. Now 8.125 is a good number since 0.125= 2^-3 exactly. If I input, say, 8.1274 instead, the MATLAB tool would have to tell me the nearest approximation in Fixed Point binary.
Can somebody please advise if this is possible in MATLAB or Simulink or both?

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 10 月 1 日
If you have the Fixed Point Toolbox, you can use it. You can get all the bits together of a fixed-point object as a string using bin() or you can is bitget() or similar routines.
You might like to look at quantize

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by