How can I change precision in Matlab?

2 views (last 30 days)
Kyriacos Patsalides
Kyriacos Patsalides on 26 Apr 2017
Commented: Stephen23 on 26 Apr 2017
I am comparing some values between Fortran 90 and Matlab. The calculated value of A in Fortran has 20 digits, thus when calculating B it also has 20 digits. The same calculations are made in Matlab but the calculated value of A has 15 digits, thus the calculation of B will be different from the B calculated in Fortran.
How can I make Matlab calculating everything with a precision of 20 digits such as Fortran does?

Answers (1)

KL
KL on 26 Apr 2017
try vpa
vpa(B,20)
  2 Comments
Kyriacos Patsalides
Kyriacos Patsalides on 26 Apr 2017
I tried that one but then Matlab gives my an error. I know that Matlab can provide up to 16 digits but I don't know if i must have like a specific version of Matlab that will allow me to use vpa
Stephen23
Stephen23 on 26 Apr 2017
@Kyriacos Patsalides: vpa does not require a special version of MATLAB, but it is a part of the symbolic toolbox. If you do not have that toolbox installed and have a license for it then you will not be able to use it.

Sign in to comment.

Categories

Find more on Fortran with MATLAB in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!