How can I read a text file into a list?
35 ビュー (過去 30 日間)
古いコメントを表示
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'.
0 件のコメント
採用された回答
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 Center および File Exchange で Text Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!