About copying txt to matrix

1 回表示 (過去 30 日間)
Utku Agtas
Utku Agtas 2020 年 8 月 6 日
コメント済み: Utku Agtas 2020 年 8 月 6 日
Hello,
I have a.txt file like this;
0.0 1548.52 /
200.0 1530.29 /
250.0 1526.69 /
400.0 1517.78 /
600.0 1509.49 /
800.0 1504.30 /
1000.0 1501.38 /
1200.0 1500.14 /
1400.0 1500.12 /
1600.0 1501.02 /
1800.0 1502.57 /
2000.0 1504.62 /
2200.0 1507.02 /
2400.0 1509.69 /
2600.0 1512.55 /
2800.0 1515.56 /
3000.0 1518.67 /
3200.0 1521.85 /
3400.0 1525.10 /
3600.0 1528.38 /
3800.0 1531.70 /
4000.0 1535.04 /
4200.0 1538.39 /
4400.0 1541.76 /
4600.0 1545.14 /
4800.0 1548.52 /
5000.0 1551.91 /
and I want to copy that to a matrix which has 2 columns and and rows that equal to number of lines. I would be grateful if you help. Thank you.

採用された回答

Walter Roberson
Walter Roberson 2020 年 8 月 6 日
filename = 'whatever.txt';
fid = fopen(filename, 'rt');
data = cell2mat( textscan(fid, '%f%f%*s') );
fclose(fid);
  1 件のコメント
Utku Agtas
Utku Agtas 2020 年 8 月 6 日
Thanks!

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

その他の回答 (1 件)

Sudheer Bhimireddy
Sudheer Bhimireddy 2020 年 8 月 6 日
Try this:
Look at the examples given there you should be able to do it in the similar manner.
  1 件のコメント
Utku Agtas
Utku Agtas 2020 年 8 月 6 日
Thanks for the answer!

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by