If your text data is contained in multiple files in a folder, then you can import the text data into MATLAB using a file datastore.
Create a file datastore for the example sonnet text files. The examples sonnets have file names "exampleSonnetN.txt", where N is the number of the sonnet. Specify the read function to be extractFileText.
bag — Input bag-of-words or bag-of-n-grams model bagOfWords object | bagOfNgrams object
Input bag-of-words or bag-of-n-grams model, specified as a bagOfWords object or a bagOfNgrams object.
documents — Input documents tokenizedDocument array | string array of words | cell array of character vectors
Input documents, specified as a tokenizedDocument array, a string array of words, or a cell array of
character vectors. If documents is a string array or a cell array
of character vectors, then it must be a row vector representing a single document, where
each element is a word.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.