importdata Load data from file. importdata(FILENAME) loads data from FILENAME into the workspace. A = importdata(FILENAME) loads data into A. importdata(FILENAME, DELIM) interprets DELIM as the column separator in ASCII file FILENAME. DELIM must be a character vector or string scalar. Use '\t' for tab. importdata(FILENAME, DELIM, NHEADERLINES) loads data from ASCII file FILENAME, reading numeric data starting from line NHEADERLINES+1. [A DELIM] = importdata(...) returns the detected delimiter character for the input ASCII file. [A DELIM NHEADERLINES] = importdata(...) returns the detected number of header lines in the input ASCII file. [...] = importdata('-pastespecial', ...) loads data from the system clipboard rather than from a file. Notes: If importdata recognizes the file extension, it calls the MATLAB helper function designed to import the associated file format. Otherwise, importdata interprets the file as a delimited ASCII file. When the helper function returns more than one nonempty output, importdata combines the outputs into a structure array. For details, type "doc importdata" at the command prompt. For ASCII files and spreadsheets, importdata expects to find numeric data in a rectangular form (that is, like a matrix). Text headers can appear above or to the left of numeric data. To import ASCII files with nonnumeric characters anywhere else, including columns of character data or formatted dates or times, use TEXTSCAN instead of importdata. When importing spreadsheets with columns of nonnumeric data, importdata cannot always correctly interpret the column and row headers. Examples: 1) Import and display an image: nebula_im = importdata('ngc6543a.jpg'); image(nebula_im); 2) Using a text editor, create an ASCII file called myfile.txt: Day1 Day2 Day3 Day4 Day5 Day6 Day7 95.01 76.21 61.54 40.57 5.79 20.28 1.53 23.11 45.65 79.19 93.55 35.29 19.87 74.68 60.68 1.85 92.18 91.69 81.32 60.38 44.51 48.60 82.14 73.82 41.03 0.99 27.22 93.18 89.13 44.47 17.63 89.36 13.89 19.88 46.60 Import the file, and view columns 3 and 5: M = importdata('myfile.txt', ' ', 1); for k = [3, 5] disp(M.colheaders{1, k}) disp(M.data(:, k)) disp(' ') end See also readtable, VideoReader, imread, load, open, uiimport. Documentation for importdata