필터 지우기
필터 지우기

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개)

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 CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by