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

6 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 15 Jun. 2011
No there isn't.
Please see this earlier Question

Weitere Antworten (2)

John D'Errico
John D'Errico am 16 Jun. 2011
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 Kommentare
John D'Errico
John D'Errico am 16 Jun. 2011
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 am 16 Jun. 2011
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.

Melden Sie sich an, um zu kommentieren.


David Graff
David Graff am 10 Sep. 2018
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.

Community Treasure Hunt

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

Start Hunting!

Translated by