Vpa conversion of whole file

6 views (last 30 days)
Ahmet Parker
Ahmet Parker on 20 Apr 2022
Edited: John D'Errico on 22 Apr 2022
Hi,
I have a matlab code which has many lines of code. I need variable precision arithmetic calculations. I want to use vpa and digits().
I do not want to convert all my files (inputs, assignments, initializations) into vpa() format. Is there an easy way to do it?
All my calculations will be in variable precision arithmetic (vpa). I want to see if using more digits change my results.
Thanks in advance

Accepted Answer

John D'Errico
John D'Errico on 22 Apr 2022
Edited: John D'Errico on 22 Apr 2022
I'm sorry. You cannot now convert those files automatically, to take lines like
a = 5;
And automatically have MATLAB see those lines as
a = vpa(5);
with some number of digits specified, where all double precision numbers as created in all of your files are now converted automatically and on the fly to VPA.
Could you use some text processing to do so? That is possible if your code if pretty simplistic, but I would consider it suspect unless you are highly skilled at using tools like regular expressions in MATLAB, and even then, I'd be wary of bugs you may introduce.
Oh, and even if you could do this? Your code would now run quite slowly, because MATLAB is not optimized to use all symbolic computations.

More Answers (0)

Tags

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by