Matlab: Read more data from a single column file

조회 수: 1 (최근 30일)
ph
ph 2015년 4월 23일
답변: Ingrid 2015년 4월 23일
Hi all,
I have a text file formatted as follow:
((filename)
(first-variable
1
2
3
...
)
(second-variable
1
2
3
...
))
and I would read it and create two vectors named "first-variable" and "second-variable" and filled by the numbers in the file (here 1 2 3 ....). Ny the way I know the total number of points in each vector.
Any suggestion on how to that?
Thanks in advance, Filippo

답변 (1개)

Ingrid
Ingrid 2015년 4월 23일
you can just use textscan with %f format and 2 headerlines. This will read in the first vector and will stop as soon as it hits the string defining the start of the second variable. Than call textscan again on the same fid and it will continue from the line it stopped before (so do not forget to add one headerline in this case to skip the string part)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by