How to use coder.unroll in a while loop

1 回表示 (過去 30 日間)
Life is Wonderful
Life is Wonderful 2022 年 8 月 16 日
コメント済み: Life is Wonderful 2022 年 8 月 16 日
Hi
I'm looking for a sample code of how to use "coder. unroll" in a while loop. I intend to perform a division operation and want to unroll the loop if I achieve the required accuracy level.
For example,
format long g
a = (4);
b = (6);
T = numerictype('Signed', true,...
'WordLength', 64,...
'FractionLength', 60);
quotient = divide(T,a,b)
quotient =
0.666666666666667
and I want to stop the division process when a certain fractional bit accuracy, say 0.6667, is reached.

採用された回答

Walter Roberson
Walter Roberson 2022 年 8 月 16 日
coder.unroll() by itself cannot do that. coder,unroll() always unrolls the number of times given in the for loop. The loop limits do not need to be constant inside the function being unrolled, but if not then during the code generation phase, the limit must be given as a numeric constant. If you had two different limits that you wanted to unroll to, then you would have to generate code twice, once for each limit.
  6 件のコメント
Walter Roberson
Walter Roberson 2022 年 8 月 16 日
I seem to recall that the CORDIC division algorithm stops early if it reaches its goal.
Life is Wonderful
Life is Wonderful 2022 年 8 月 16 日
Thank you very much for your kind assistance. !!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by