Single and double precision matlab

  • Thread starter Thread starter sara_87
  • Start date Start date
  • Tags Tags
    Matlab Precision
AI Thread Summary
MATLAB defaults to double precision for all computations, and there is no global setting to change this to single precision for all operations. Users can define individual variables as single precision using the single(A) function, which ensures that operations between these variables yield single precision results. However, existing code with multiple variables will require manual adjustments to ensure single precision is used throughout. This limitation can be challenging for larger codebases. Ultimately, users must define their variables as single precision from the start to achieve the desired output.
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!
 
Back
Top