Main Content

Managing Data

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.

The nominal, ordinal, and dataset data types are unique to Statistics and Machine Learning Toolbox, and are no longer recommended. 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
dummyvarCreate dummy variables
onehotencodeEncode data labels into one-hot vectors (Since R2021b)
onehotdecodeDecode probability vectors into class labels (Since R2021b)
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
mat2dataset(Not Recommended) Convert matrix to dataset array
cell2dataset(Not Recommended) Convert cell array to dataset array
struct2dataset(Not Recommended) Convert structure array to dataset array
table2dataset(Not Recommended) Convert table to dataset array
dataset2cell(Not Recommended) Convert dataset array to cell array
dataset2struct(Not Recommended) Convert dataset array to structure
dataset2tableConvert dataset array to table
export(Not Recommended) Write dataset array to file
ismissing(Not Recommended) Find dataset array elements with missing values
join(Not Recommended) Merge dataset array observations

Classes

dataset(Not Recommended) Arrays for statistical data

Topics

  • Sample Data Sets

    Data sets contain individual data variables, description variables with references, and dataset arrays encapsulating the data set and its description, as appropriate.

  • Grouping Variables

    Grouping variables are utility variables used to group or categorize observations.

  • Dummy Variables

    Dummy variables let you adapt categorical data for use in classification and regression analysis.

  • Test Differences Between Category Means

    Test for significant differences between category (group) means using a t-test, two-way ANOVA (analysis of variance), and ANOCOVA (analysis of covariance) analysis.

  • Linear Regression with Categorical Covariates

    Perform a regression with categorical covariates using categorical arrays and fitlm.