How can I read the entire contents of a file into a cell array with one line per cell?
14 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I would like to read the entire contents of a file. In the end, I'd like to have a cell array, where each cell contains a line from the file.
Risposta accettata
MathWorks Support Team
il 27 Giu 2009
There is no single function that does this in MATLAB, although several functions can be combined to do this.
For instance,
str = fileread('foo.txt');
lines = regexp(str, '\r\n|\r|\n', 'split');
reads "foo.txt" into a string, and then splits the string into cells according to newline combinations.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su MATLAB Report Generator in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!