0

I have a text file which stores some data and at the end includes the parameters the experiment used.

The only information I have about these is:

The annotation consists of a series of pairs (name, value). The name is encoded as a null-terminated sequence of ASCII characters while the value is saved as an 8-byte floating point number.

After parsing the data in the file I am attempting to read off these annotations. I am doing something like

filename='2014-07-15-13;16;32.aia'
fid = fopen(filename)
readheader(fid) %gets information about number of lines of data
readdata(fid) %extracts data
A=scanf(fid,'%s %lf')

The output is a string of integers which begins something like:

A =

      76
     111
      97
     100
      70
     114
     101
     113
     ...

If instead I try A=fscanf(fid,'%s')

I get something like

A =

LoadFreq 333333@CoolingOptimumFreq       ð?ResonanceRampTime š™™™™™¹?Res       ð?

Which looks like the floating point numbers are being read in ASCII encoding.

What I want is something like:

LoadFreq 1 CoolingOptimumFreq 1 SweepTime 100 Res 30

But I haven't been able to figure out how to read the word in ASCII, then read the next part as a double float and continue until the end of the file. I am guessing that dealing with the "null-terminated sequence" for the ASCII characters is key to all this.

ptbrown
  • 101
  • 2
  • 10
  • handling null-terminated ascii string http://stackoverflow.com/questions/2037209/what-is-a-null-terminated-string – Yvon Aug 12 '14 at 19:26
  • To read until the end of file, use this http://www.mathworks.com/help/matlab/ref/feof.html – Yvon Aug 12 '14 at 19:28

0 Answers0