How to import a txt file with specific format
Mostra commenti meno recenti
I need to build the data to construct a report with differents fields like s11 s21 and so on.
I have a text files looks similar to the following:
Frequency / GHz S1,1/abs,linear S1,1/arg,degrees
----------------------------------------------------------------------------------------------------------------
0.5 0.23338409 174.80629
0.5055 0.23355055 174.72296
0.511 0.23371744 174.63905
0.5165 0.23388473 174.55456
Frequency / GHz S2,1/abs,linear S2,1/arg,degrees
----------------------------------------------------------------------------------------------------------------
0.5 0.97077225 314.88972
0.5055 0.97072179 314.39626
0.511 0.97067132 313.90283
0.5165 0.97062083 313.40943
0.522 0.97057033 312.91605
Risposta accettata
Più risposte (1)
Chad Greene
il 24 Nov 2014
Use textscan.
fid = fopen('myfile.txt');
data = textscan(fid,'%f %f %f','headerlines',2);
frequency = data{1};
S1 = data{2};
S2 = data{3};
You'll need to verify that the number of headerlines is correct.
2 Commenti
Efren Acevedo
il 24 Nov 2014
Chad Greene
il 24 Nov 2014
Can you upload the text file so I can see what you mean?
Categorie
Scopri di più su Large Files and Big Data 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!