Save data points from a single line in a text file.
이전 댓글 표시
How do I pull data values from 1 line in a text file to a nx3 array?
My issue is that thousands of data points are on one single line in the text file, they're are also in the following format:
Data1 {{x1 x2 x3} {r1 r2 r3}...} Data2 {{x4 x5 x6} {r4 r5 r6}....} Data3 {{x7 x8 x9} {r7 r8 r9}....} ....
and it goes on for thousands of data points.
I want to extract and put these data points in nx3 arrays:
data1 = [x1 x2 x3; r1 r2 r3;...]
data2 = [x4 x5 x6; r4 r5 r6;...]
data3 = [x7 x8 x9; r7 r8 r9;...]
and so on...
Does this explain my need? Please help..
댓글 수: 5
Guillaume
2015년 11월 22일
편집: Walter Roberson
2015년 11월 23일
However you come to it (dynamically created, using switch or if), having numbered variables is a bad idea. We're going to keep on saying it because sooner or later you're going to want to operate over all these numbered variables at once and have to resort to the dreaded eval. Much better is to use a cell array / matrix.
data{i} %with i = 1:n
is always better than
data1
...
datan
In any case, in order to answer your question, we need to see a sample of your file. Particularly as you seem to have given a slightly different format in your other question (are the '{' part of the format? are the numbers integers of doubles? etc.). Please, attach a sample file to your question.
BlueSky
2015년 11월 22일
Walter Roberson
2015년 11월 23일
Do the lines of interest always have '::' in them? Or is the line of interest always line 5 and no other lines? Are there only the four variables PrepStep_fax_temp_data_r and t and y and u ?
BlueSky
2015년 11월 23일
BlueSky
2015년 11월 23일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Text Data Preparation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!