Reading Text and Parsing by Character
Mostra commenti meno recenti
Hi, I need to somehow read in a text file with no standard delimiters (spaces,tabs,ect.) and parse it by character into a long single row array.
For example,
rand.txt = "thequickbrownfoxjumpsoverthelazydog"
finalarray = ['t' 'h' 'e' 'q' 'u' 'i' 'c' 'k'....]
Any advice??
Thanks in advance!
4 Commenti
Oleg Komarov
il 30 Lug 2012
The example you provided is misleading (or I don't understand it) since the second line of code will return exactly the first line.
Nikolay Rodionov
il 30 Lug 2012
Walter Roberson
il 30 Lug 2012
[] is the horizontal concatenation operator. ['a' 'b'] has exactly the same result as 'ab' . Are you looking for a cell array of strings? {'a' 'b'} ?
Nikolay Rodionov
il 31 Lug 2012
Risposta accettata
Più risposte (1)
Walter Roberson
il 30 Lug 2012
finalarray = num2cell(rand.txt);
1 Commento
Nikolay Rodionov
il 31 Lug 2012
Categorie
Scopri di più su Characters and Strings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!