필터 지우기
필터 지우기

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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by