How to convert a string to a numeric (large decimal point number)
Show older comments
Hello,
I am currently dealing with the conversion of a symbolic number with 32-digits, including the decimals. So for example, x = 8.7205519972788820837195089552552.
I need to pass in a DOUBLE of the size 3x1 into the fmincon() function for the initial 'X0' with this precision for my algorithm to work, and not a symbolic 3x1.
I tried using the vpa(x) function but it obviously returns a symbolic. The following code turns x into a string of the CHAR datatype. Is there a way I can convert str to a numeric (while keeping my 32-digit precision) and therefore a DOUBLE in case of multiple numbers in a vector of similar size to x?
x = vpa(x);
str = evalc('disp(x)');
If not, is there another way to work with atleast 32-digits precision? for example, is there a way to tell MATLAB to not round off numbers in between function calls?
Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Symbolic Math Toolbox 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!