Random function from a text file?
Mostra commenti meno recenti
Basically, I have a text file with a bunch of words on it. I'm not sure how I can use MATLAB to randomly select one word.
Risposta accettata
Più risposte (1)
the cyclist
il 3 Dic 2011
There are many MATLAB functions that can read text from files. One possibility that might work for you is the textscan() function. That will read the file into a cell array. Then, you could randomly select one element of the cell array, perhaps using the randi() command.
>> doc textscan
>> doc randi
Those help files give the detailed syntax, and also point to other functions you might prefer to use.
1 Commento
Chris
il 3 Dic 2011
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!