Main Content

Import Text Data intoMATLAB

Use the following functions to import text data into MATLAB®. Usually, the easiest way to import text data into MATLAB is to use theextractFileTextfunction. For example, to import text from a text file, use:

str = extractFileText('sonnets.txt');
This table outlines which function to use for different file types. For more information, seeExtract Text Data from Files.

Source Function Example
Text,Microsoft®, PDF, and HTML files extractFileText str = extractFileText('sonnets.txt');
CSV andMicrosoft Excel®files readtable tbl = readtable('weatherReports.csv','TextType','string');
HTML code extractHTMLText str = extractHTMLText('

THE SONNETS

by William Shakespeare

');
PDF forms readPDFFormData data = readPDFFormData('weatherReportForm1.pdf');

See Also

|||

Related Topics