Hi
I am trying to use sscanf to extract data from a string, but it is truncating my floating point number. The code I am using is:
sscanf(tempstr, '%f V,%d counts,%d ms')
The data is like this: 0.2981427192 V,34 counts,500 ms
I get: ans =
0.2981
34.0000
500.0000
I want all the floating point digits. I have tried to specify a length (%12f), and numerous other things, none of which have worked. Any help would be appreciated.
Thanks Rebecca

댓글 수: 1

Stephen23
Stephen23 2016년 5월 6일
편집: Stephen23 2016년 5월 6일
@Rebecca Prescott: Don't worry, MATLAB has not eaten your digits! Actually sscanf is working fine: it is just how the values are displayed. See format for more info on different display options.

댓글을 달려면 로그인하십시오.

 채택된 답변

Star Strider
Star Strider 2016년 5월 6일

2 개 추천

Type:
format long g
in your script or Command Window before your sscanf call. All the digits should be visible.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Language Support에 대해 자세히 알아보기

제품

태그

Community Treasure Hunt

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

Start Hunting!

Translated by