필터 지우기
필터 지우기

Is there a way to change MATLAB defaults, so that all workspace floating-point values to be stored in single precision?

조회 수: 9 (최근 30일)
Hi,
Could anyone suggest me a statement, function, code, etc. so that I can change MATLAB's defaults for storing the workspace floating-point values in single-precision? (instead of the default double-precision)
I didn't find a statement for this purpose such as 'format' that changes the workspace numeric-value show format..
Thanks so much

채택된 답변

Walter Roberson
Walter Roberson 2011년 6월 15일
No there isn't.
Please see this earlier Question

추가 답변 (2개)

John D'Errico
John D'Errico 2011년 6월 16일
This is not possible in MATLAB. Anyway, it is rarely a good idea to work in single. It is actually slower in many cases anyway. The memory saved is hardly worth it compared to the risk of the loss in precision. If you absolutely must, use single on only the largest arrays.
Better yet is to buy some memory and use 64 bit MATLAB for your work. RAM is cheap these days.
  댓글 수: 3
John D'Errico
John D'Errico 2011년 6월 16일
No computational environment can ever be perfect, since compromises must always be made in terms of simplicity of use versus speed of your code, ease of learning the tool, and many other metrics of importance. As well, there are issues of forward compatibility to be considered. For example, introduce the new ability to specify the working precision as single rather than double, and you will probably introduce bugs into existing code that presumed all numbers were doubles by default.
Of course, my goals for the perfect language will surely be different from yours.
Daniel Shub
Daniel Shub 2011년 6월 16일
Manually changing the precision of all variables is going to be a nightmare. Every time you perform an operation on the variables there is a strong likelihood that it will be reconverted back to a double. If you really need to work with single precision values, MATLAB is not the right language for you. If you are trying to save memory, just buy some RAM.

댓글을 달려면 로그인하십시오.


David Graff
David Graff 2018년 9월 10일
We work in an embedded systems environment where we have to use floats. There are dedicated Matlab tools to simulate this environment but they are clunky. It would be nice to be able to quickly prototype algorithms in Matlab in a float environment to see if they don't lose too much precision.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by