Main Content

Managing Data

R2026b
Data import and export, and grouping variables

Transfer data into and out of MATLAB® using several different file formats. Valid formats include tabular data, tab-delimited files, Microsoft® Excel® spreadsheets, and SAS® XPORT files. For a table of supported file formats and their associated import and export functions, see Supported File Formats for Import and Export. Alternatively, you can import data interactively by using the Import Tool. Statistics and Machine Learning Toolbox™ supports many, but not all, of the data types available in MATLAB. For more information, see Supported Data Types.

For greater cross-product compatibility, use the categorical or table data types available in MATLAB. For more information, see Create Categorical Arrays or Create Tables and Assign Data to Them, or watch Tables and Categorical Arrays.

Functions

expand all

casereadRead case names from file
casewriteWrite case names to file
tblreadRead tabular data from file
tblwriteWrite tabular data to file
tdfreadRead tab-delimited file
xptreadCreate table from data stored in SAS XPORT format file
dataset(Not Recommended) Arrays for statistical data
dataset2tableConvert dataset array to table
dummyvarCreate dummy variables
onehotencodeEncode data labels into one-hot vectors
onehotdecodeDecode probability vectors into class labels
gplotmatrixMatrix of scatter plots by group
grp2idxCreate index vector from grouping variable
gscatterScatter plot by group
nominal(Not Recommended) Arrays for nominal data
ordinal(Not Recommended) Arrays for ordinal data
countPredictorsAfterCategoricalEncodingNumber of predictors in tabular data after encoding categorical variables (Since R2026a)

Topics