How can I read a text file into a list?
16 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Gabriel Gregory
il 6 Nov 2015
Commentato: Gabriel Gregory
il 6 Nov 2015
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 Commenti
Risposta accettata
Robert Snoeberger
il 6 Nov 2015
You can read into a cell array:
>> data = fileread('file_name');
>> x = strsplit(data);
>> x{1}
ans =
ABC
>> x{2}
ans =
DEF
>>
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Text Files in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!