FUNCTION REFERENCE

importdata

Load data from a text, image, audio or MAT file.

Load data from a text, image, audio or MAT file.

Syntax

A = importdata(filename)

Syntax

[A, delimiter, headerlines] = importdata(filename, delimiter, headerlines)

Numeric text gives a matrix (short rows padded with NaN). Header lines give a struct with data, textdata and colheaders; leading row labels give data, textdata and rowheaders; text only gives a cell column of lines. The delimiter is detected (comma, tab, then spaces) unless given. PNG files return the image, WAV files a struct with data and fs, and MAT files the variable (or a struct of all variables).

Example

d=tempname(pwd); mkdir(d); f=fullfile(d,'n.csv'); fid=fopen(f,'w'); fprintf(fid,'1,2\n3,4\n'); fclose(fid); A=importdata(f); rmdir(d,'s'); A   % [1 2; 3 4]

Differences from MATLAB: Only the image and audio formats of imread and audioread; spreadsheets and the clipboard are not supported yet.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.