How to import a txt file with specific format
古いコメントを表示
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
採用された回答
その他の回答 (1 件)
Chad Greene
2014 年 11 月 24 日
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 件のコメント
Efren Acevedo
2014 年 11 月 24 日
Chad Greene
2014 年 11 月 24 日
Can you upload the text file so I can see what you mean?
カテゴリ
ヘルプ センター および File Exchange で Text Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!