reduce the working precision

5 ビュー (過去 30 日間)
Sivasankaran Sivanandam
Sivasankaran Sivanandam 2021 年 6 月 4 日
回答済み: Andy Bartlett 2021 年 6 月 7 日
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.

回答 (2 件)

Steven Lord
Steven Lord 2021 年 6 月 4 日
Take a look at Fixed-Point Designer. It may do what you want.

Andy Bartlett
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.

カテゴリ

Help Center および File ExchangeFixed-Point Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by