필터 지우기
필터 지우기

How can I read a text file into a list?

조회 수: 16 (최근 30일)
Gabriel Gregory
Gabriel Gregory 2015년 11월 6일
댓글: Gabriel Gregory 2015년 11월 6일
I have a text file containing strings in each row, e.g.
ABC
DEF
PQR
I would like to end up with an object that i can index - i.e. x(1) = 'ABC', x(2) = 'DEF', x(3) = 'PQR'.

채택된 답변

Robert Snoeberger
Robert Snoeberger 2015년 11월 6일
You can read into a cell array:
>> data = fileread('file_name');
>> x = strsplit(data);
>> x{1}
ans =
ABC
>> x{2}
ans =
DEF
>>

추가 답변 (0개)

카테고리

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