Extracting data from a text file into an array

8 visualizaciones (últimos 30 días)
BlueSky
BlueSky el 16 de Nov. de 2015
Editada: Stephen23 el 19 de Jun. de 2019
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.

Respuestas (2)

Walter Roberson
Walter Roberson el 16 de Nov. de 2015

Stephen23
Stephen23 el 16 de Nov. de 2015
Editada: Stephen23 el 19 de Jun. de 2019
  1 comentario
BlueSky
BlueSky el 20 de Nov. de 2015
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.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by