Save data points from a single line in a text file.
Mostra commenti meno recenti
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 Commenti
Guillaume
il 22 Nov 2015
Modificato: Walter Roberson
il 23 Nov 2015
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
il 22 Nov 2015
Walter Roberson
il 23 Nov 2015
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
il 23 Nov 2015
BlueSky
il 23 Nov 2015
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Text Data Preparation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!