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!