Reading a text file containing strings.
Show older comments
I have a data recorded from a sensor every day which is listed below:
34312810010110000000000000000000000000000000000000000000000000000000000000000 34312810010210000000000000000000000000000000000000000000000000000000000000000 34312810010310000000000000000000000000000000000000000000000000000000000000000 34312810010410000000000000000000000000000000000000000000000000000000000000000 34312810010510000000000000000000000000000000000000000000000000000000000000000 34312810010610000000000000000000000000000000000000000000000000000000000000000 34312810010710000000000000000000000000000000000000000000000000000000000000000 34312810010810000000000000000000000000000000000000000000000000000000000000000 34312810010910000000000000000000000000000000000000000000000000000000000000000 34312810011010000000000000000000000000000000000000000000000000000000000000000 34312810011110000000000000000000000000000000000000000000000000000000000000000
I have written a code for interpreting the data as follows:
str = '34312810010110000000000000000000000000000000000000000000000000000000000000000'
D1=str(1) % Element Indicator
D2=str(2:6) % Index number of the station
D3=str(7:8) % Year
D4=str(9:10) % Month
D5=str(11:12) % Date
D6=str(13) % Record Number
and so on
D7
:
:
etc as upto the end of the first line and later I convert these strings to numbers using strl2num.
I am able to process the data for one line with this code, how to do the same process repeadedly for 'n' number of lines keeping the whole data in a text file.
Thanks in advance.
Lakshmi.
Accepted Answer
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!