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

62 views (last 30 days)
math98
math98 on 15 Jun 2011
Answered: David Graff on 10 Sep 2018
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

More Answers (2)

John D'Errico
John D'Errico on 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 Comments
Daniel Shub
Daniel Shub on 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.

Sign in to comment.


David Graff
David Graff on 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!