Drop msb of fi object, producing a new fi object
4 ビュー (過去 30 日間)
古いコメントを表示
This seems to do what I want.
Is there anything to go wrong with this approach?
Seems like I have dropped the msb from the number, changing it from a 5.2 fi numbe to a 4.2 fi number
>> a = fi(3,1,5,2);
>> b = fi(a,1,4,2);
>> a.bin
ans =
01100
>> b.bin
ans =
0111
0 件のコメント
回答 (1 件)
Shivansh
2024 年 6 月 22 日
Hi Mike,
I think you have misinterpreted the 'fi' function and its application.
The 'fi' function is used to represent the numbers in fixed point by fixing the word length(or even fraction length) allowed for the number.
In the above mentioned example, fi(3,1,5,2) means you are storing 3 in a signed fixed point representation with a world length of 5 and fraction length of 2.
You can understand this better using the below code snippet:
a = fi(3,1,5,2)
Now, moving on the next example. You have reduced the word length for 'a' by keeping the same fraction length. Now, you can't represent 3 using 2 bits which will result in change in the value.
b = fi(a,1,4,2)
The result stored in b is the maximum possible value for a world length of 4 with franction length of 2.
For the results using the 'bin' function, they represent the stored integer form of these fixed point numbers in the binary form. You can verify it by first evaluating them to base 10 integer and then dividing them by 2^fractionlength. This will get you the same number represented in the fixed point representation.
You can refer to the following documentation for more information on the 'fi' representation:
I hope it helps!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Fixed Point についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!