Extracting data from a text file into an array

8 ビュー (過去 30 日間)
BlueSky
BlueSky 2015 年 11 月 16 日
編集済み: Stephen23 2019 年 6 月 19 日
I have a large text file, I know how to get to the line that I want to extract the data from. The line contains thousands of numbers in the form:
Data1 x1 y1 z1 x2 y2 z2
Data2 x3 y3 z3 x4 y4 z4
I want Data1 to be the name of a new nx3 array and every number that comes after Data1 until the next Data2 to be stored under Data1 and so forth...
Any help/hints would be appreciated. Thanks.

回答 (2 件)

Walter Roberson
Walter Roberson 2015 年 11 月 16 日

Stephen23
Stephen23 2015 年 11 月 16 日
編集済み: Stephen23 2019 年 6 月 19 日
  1 件のコメント
BlueSky
BlueSky 2015 年 11 月 20 日
So, how do I pull those data values from the 1 line in the text file to a nx3 array? That is my issue. I can avoid dynamically naming those array but doing some sort of If statement and if it matches the name in the string I would assign it a name.
My issue is that the 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; x4 x5 x6; r4 r5 r6; x7 x8 x9; r7 r8 r9]
Does this explain my need better? Please help. Thanks.

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

Community Treasure Hunt

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

Start Hunting!

Translated by