Question about reading a file with mixed data in lines

3 ビュー (過去 30 日間)
Brian
Brian 2013 年 10 月 17 日
コメント済み: Brian 2013 年 10 月 18 日
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!

採用された回答

Walter Roberson
Walter Roberson 2013 年 10 月 17 日
fscanf(fid, '(10 (%d%d%x%d%d))')
  2 件のコメント
Brian
Brian 2013 年 10 月 17 日
Thanks, I will try this out.
Brian
Brian 2013 年 10 月 18 日
Thanks! This worked perfectly.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by