Is there a way to change MATLAB defaults, so that all workspace floating-point values to be stored in single precision?
7 ビュー (過去 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
0 件のコメント
採用された回答
その他の回答 (2 件)
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
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
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
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!