ASCII to Decimal numbers

3 views (last 30 days)
Adelaide Bradicich
Adelaide Bradicich on 20 Aug 2018
Commented: Star Strider on 20 Aug 2018
I have an instrument that outputs ascii instead of decimal numbers. How do you convert between the two formats? I've attached a text file of the data I'm dealing with. It's supposed to be packed as 4-byte single precision floating point binary, in little endian format. I'm new to data types, so if someone could also tell me what exactly that means it would be greatly appreciated! Thanks in advance for your help.

Accepted Answer

Star Strider
Star Strider on 20 Aug 2018
It looks like a binary file. See the documentation on the fread (link) function for details.
Try this, to see if it looks like the result you expect:
fidi = fopen('ascii_data.txt','r');
D = fread(fidi, 'single', 'ieee-le');
fclose(fidi);
figure
plot(D)
grid
This should get you started, and you will likely have to experiment to get the result you want.
I have no recent experience with these sorts of files, and when I was working with them quite a while ago, knew the result to expect.
  2 Comments
Adelaide Bradicich
Adelaide Bradicich on 20 Aug 2018
That works exactly like I need it to! Thanks so much.
Star Strider
Star Strider on 20 Aug 2018
As always, my pleasure!

Sign in to comment.

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!