Why does str2num truncate my number so early?
조회 수: 6 (최근 30일)
이전 댓글 표시
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!