reduce the working precision
6 ビュー (過去 30 日間)
古いコメントを表示
I have some 2 dimesional array (varaibles), like A(100, 100), B(100, 100). Matlab takes 16 decimal places for all calculations. But, I need to fix ONLY 6 decimal palces for all my calculations (numerical simulations). How do i fix all my varibales in my code with only 6 or 8 decimal places.
0 件のコメント
回答 (2 件)
Andy Bartlett
2021 年 6 月 7 日
I'm guessing you want your simulation code to be smaller and faster.
Single precision floating-point provides around 7 decimal digits of accuracy and can achieve that goal.
Make sure the key entry points to your algorithm are single.
If the inputs are all singles, most of your calculations will be produce single precision results.
A = single( rand(3,2) );
B = single( rand(2,4) );
C = A * B
C =
3×4 single matrix
0.68457 0.23552 0.11531 1.2855
0.39312 0.13022 0.069436 0.83144
0.59251 0.20564 0.098654 1.0794
Converting a MATLAB m-file from double precision to single precision can be automated using convertToSingle.
If you have a Simulink subsystem in double precision that you wanted to convert to single, the conversion can also be automated.
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!