how to use textscan to read this text file properly

3 ビュー (過去 30 日間)
ELI
ELI 2014 年 1 月 3 日
編集済み: Azzi Abdelmalek 2014 年 1 月 3 日
Hi, I have a text file that I cannot read it propely:
'3.700000e+00 2.500000e+00 3.500000e+00 3 6.945462e+00 R M1 (1)'
'3.700000e+00 2.500000e+00 -3.500000e+00 3 2.764839e+00 L M1 (1)'
'1 2 2.400000e+00 3 4.719051e+00 R M1 (2)'
'1 2 -2.400000e+00 3 3.441881e+00 L M1 (2)'
'-1.700000e+00 1.500000e+00 2.700000e+00 4 4.700973e+00 R M1 (3)'
it has 5 columns of data and 1 column of string.
could you help me?
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 3 日
編集済み: Azzi Abdelmalek 2014 年 1 月 3 日
In your text file, your data are like this
'3.700000e+00 2.500000e+00 3.500000e+00 3 6.945462e+00 R M1 (1)'
or
3.700000e+00 2.500000e+00 3.500000e+00 3 6.945462e+00 R M1 (1)
Also, there are three columns for strings
ELI
ELI 2014 年 1 月 3 日
It's like the second option you mentioned.

サインインしてコメントする。

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 3 日
編集済み: Azzi Abdelmalek 2014 年 1 月 3 日
fid = fopen('file.txt');
res=textscan(fid,'%f %f %f %d %f %s %s %s')
fclose(fid);
celldisp(res)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by