Question about reading a file with mixed data in lines

1 view (last 30 days)
Brian on 17 Oct 2013
Commented: Brian on 18 Oct 2013
Thanks for reading this,
I think this is a simple question to answer, but for some reason I can't get this to work. What I am trying to do is read the line:
(10 (0 1 c91 0 3))
where the '0 1 c91 0 3))' can be arbitrary: '(10 (' is always assumed to be in the file. The former is dependent on the number of data points I want to collect.
What I want to do is parse the '0 1 c91' information inside: I don't care about the '0 3)) after, and I don't care about the '(10 (' before. The c91 in particular is crucial for what I use later with fscanf, where I read a certain number of rows, the number of rows being the decimal vale of hexadecimal c91.
Is this possible? Thanks for any advice!

Accepted Answer

Walter Roberson
Walter Roberson on 17 Oct 2013
fscanf(fid, '(10 (%d%d%x%d%d))')

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by