sscanf is truncating my floating point number
2 views (last 30 days)
Show older comments
Rebecca Prescott
on 6 May 2016
Commented: Image Analyst
on 6 May 2016
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 Comment
Accepted Answer
Star Strider
on 6 May 2016
Type:
format long g
in your script or Command Window before your sscanf call. All the digits should be visible.
More Answers (0)
See Also
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!