Why does str2num truncate my number so early?
3 ビュー (過去 30 日間)
古いコメントを表示
Andrew Reibold
2014 年 6 月 23 日
コメント済み: Jairo Andrés Gutiérrez Suárez
2022 年 2 月 7 日
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 件のコメント
採用された回答
その他の回答 (1 件)
Sara
2014 年 6 月 23 日
Use
sprintf
so you can control the precision you want.
3 件のコメント
Jairo Andrés Gutiérrez Suárez
2022 年 2 月 7 日
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?
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!