reduce the working precision

조회 수: 2 (최근 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 CenterFile Exchange에서 Fixed-Point Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by