This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Convert documents to cell array of string vectors


C = doc2cell(documents)



C = doc2cell(documents) converts a tokenizedDocument array to a cell array. The entries of C are string arrays containing the corresponding words in each document.


collapse all

Convert a tokenizedDocument array to a cell array of string vectors.

documents = tokenizedDocument([ ...
    "an example of a short sentence" ...
    "a second short sentence"])
documents = 
  1x2 tokenizedDocument:

    6 tokens: an example of a short sentence
    4 tokens: a second short sentence

C = doc2cell(documents)
C = 1x2 cell array
    {1x6 string}    {1x4 string}

View the first element of the cell array.

ans = 1x6 string array
    "an"    "example"    "of"    "a"    "short"    "sentence"

Input Arguments

collapse all

Input documents, specified as a tokenizedDocument array.

Output Arguments

collapse all

Output cell array of string vectors. Each element of C is a string vector containing the words of the corresponding document.

Introduced in R2017b