Is there a way to change MATLAB defaults, so that all workspace floating-point values to be stored in single precision?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
math98
el 15 de Jun. de 2011
Respondida: David Graff
el 10 de Sept. de 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
0 comentarios
Respuesta aceptada
Más respuestas (2)
John D'Errico
el 16 de Jun. de 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 comentarios
John D'Errico
el 16 de Jun. de 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
el 16 de Jun. de 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.
David Graff
el 10 de Sept. de 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.
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!