Single and double precision matlab

  • Thread starter Thread starter sara_87
  • Start date Start date
  • Tags Tags
    Matlab Precision
Click For Summary

Discussion Overview

The discussion centers around changing the default precision in MATLAB from double to single for all computations. Participants explore the implications of MATLAB's default settings and seek solutions for managing variable precision in their code.

Discussion Character

  • Homework-related

Main Points Raised

  • One participant inquires about changing the default precision in MATLAB to single for all computations, expressing frustration with the current double precision default.
  • Another participant suggests that there is no way to change the default arithmetic for all operations in MATLAB, noting that variables are double precision by default. They propose defining variables as single precision from the start to achieve single precision outputs in operations.
  • A third participant acknowledges the limitation of this approach, especially for large codebases with many variables.

Areas of Agreement / Disagreement

Contextual Notes

The discussion does not resolve the limitations of changing precision settings in MATLAB, nor does it address potential workarounds in detail.

sara_87
Messages
748
Reaction score
0

Homework Statement



MATLAB uses double precision as default.
How can I change this to single? so that all computations will be made using single precision.

Homework Equations





The Attempt at a Solution


I went to:
file
preferences
virtual reality precision: floating point: single (I changed this from double to single)

However, my computations are still being made in double precision.

I don't want to change a single variable to single precision (this is done using single(A)) I want to change all computations.

thank you.
 
Physics news on Phys.org
I do not believe there is a way to change the default arithmetic for all operations, as MATLAB variables are indeed double precision by default. Nevertheless, if you define variables to be single precision to begin with, then any operations between them will result in a single precision output.
 
oh right i see. thank you.
 
I know that's not a comforting answer if you have a large code with lots of variables -- sorry!
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 9 ·
Replies
9
Views
8K
Replies
3
Views
2K
Replies
4
Views
6K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
10
Views
4K
  • · Replies 11 ·
Replies
11
Views
6K
  • · Replies 5 ·
Replies
5
Views
3K