Extracting data from a text file into an array

10 vues (au cours des 30 derniers jours)
BlueSky
BlueSky le 16 Nov 2015
Modifié(e) : Stephen23 le 19 Juin 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.

Réponses (2)

Walter Roberson
Walter Roberson le 16 Nov 2015

Stephen23
Stephen23 le 16 Nov 2015
Modifié(e) : Stephen23 le 19 Juin 2019
  1 commentaire
BlueSky
BlueSky le 20 Nov 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.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by