Why does str2num truncate my number so early?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Andrew Reibold
am 23 Jun. 2014
Kommentiert: Jairo Andrés Gutiérrez Suárez
am 7 Feb. 2022
When I try to convert from string to number, I lose precision?
whos test_str
Name Size Bytes Class Attributes
test_str 1x9 18 char
K>> test_str
test_str =
0.067354
K>> str2num(test_str)
ans =
0.0674
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Sara
am 23 Jun. 2014
Use
sprintf
so you can control the precision you want.
3 Kommentare
Jairo Andrés Gutiérrez Suárez
am 7 Feb. 2022
Yep but that method is not efficient. There should be a way to use the exact number of decimals. What if I am using srt2num to find a folder with the same number I looked for?
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!