dataset
(Not Recommended) Arrays for statistical data
The dataset
data type is not recommended. To work with heterogeneous data,
use the MATLAB®
table
data type instead. See MATLAB
table
documentation for more information.
Description
Dataset arrays are used to collect heterogeneous data and metadata including variable and observation names into a single container variable. Dataset arrays are suitable for storing column-oriented or tabular data that are often stored as columns in a text file or in a spreadsheet, and can accommodate variables of different types, sizes, units, and so on.
Dataset arrays can contain different kinds of variables, including numeric, logical, character, string, categorical, and cell. However, a dataset array is a different class than the variables that it contains. For example, even a dataset array that contains only variables that are double arrays cannot be operated on as if it were itself a double array. However, using dot subscripting, you can operate on variable in a dataset array as if it were a workspace variable.
You can subscript dataset arrays using parentheses much like ordinary numeric arrays, but in addition to numeric and logical indices, you can use variable and observation names as indices.
Creation
Syntax
Description
creates dataset array A
= dataset(varspec
,Name=Value
)A
using the workspace variable input method
varspec
and one or more name-value arguments.
creates dataset array A
= dataset(File=filename
,Name=Value
)A
from column-oriented data in the text file
specified by filename
. Variables in A
are of type
double
if data in the corresponding column of the file, following the
column header, are entirely numeric; otherwise the variables in A
are
cell arrays of character vectors. dataset
converts empty fields to
either NaN
(for a numeric variable) or the empty
character vector (for a character-valued variable). dataset
ignores
insignificant white space in the file. You cannot specify both a file and workspace
variables as input.
creates dataset array A
= dataset(XLSFile=filename
,Name=Value
)A
from column-oriented data in the Excel® spreadsheet specified by Name=Value
. Variables in
A
are of type double
if data in the
corresponding column of the spreadsheet, following the column header, are entirely
numeric; otherwise the variables in A
are cell arrays of character
vectors.
creates a dataset array from a SAS® XPORT format file. Variable names from the XPORT format file are preserved.
Numeric data types in the XPORT format file are preserved but all other data types are
converted to cell arrays of character vectors. The XPORT format allows for 28 missing data
types. A
= dataset(XPTFile=filename
,Name=Value
)dataset
represents these in the file by an upper case letter,
'.'
or '_'
. dataset
converts
all missing data to NaN
values in A
.
Input Arguments
Properties
Object Functions
cat | (Not Recommended) Concatenate dataset arrays |
cellstr | (Not Recommended) Create cell array of character vectors from dataset array |
dataset2cell | (Not Recommended) Convert dataset array to cell array |
dataset2struct | (Not Recommended) Convert dataset array to structure |
disp | (Not Recommended) Display dataset array |
double | (Not Recommended) Convert dataset variables to double array |
end | (Not Recommended) Last index in indexing expression for dataset array |
export | (Not Recommended) Write dataset array to file |
get | (Not Recommended) Access dataset array properties |
horzcat | (Not Recommended) Horizontal concatenation for dataset arrays |
intersect | (Not Recommended) Set intersection for dataset array observations |
isempty | (Not Recommended) True for empty dataset array |
ismember | (Not Recommended) Dataset array elements that are members of set |
ismissing | (Not Recommended) Find dataset array elements with missing values |
join | (Not Recommended) Merge dataset array observations |
length | (Not Recommended) Length of dataset array |
ndims | (Not Recommended) Number of dimensions of dataset array |
numel | (Not Recommended) Number of elements in dataset array |
replaceWithMissing | (Not Recommended) Insert missing data indicators into a dataset array |
replacedata | (Not Recommended) Replace dataset variables |
set | (Not Recommended) Set and display dataset array properties |
setdiff | (Not Recommended) Set difference for dataset array observations |
setxor | (Not Recommended) Set exclusive or for dataset array observations |
single | (Not Recommended) Convert dataset variables to single array |
size | (Not Recommended) Size of dataset array |
sortrows | (Not Recommended) Sort rows of dataset array |
stack | (Not Recommended) Stack dataset array from multiple variables into single variable |
subsasgn | (Not Recommended) Subscripted assignment to dataset array |
subsref | (Not Recommended) Subscripted reference for dataset array |
summary | (Not Recommended) Print summary of dataset array |
union | (Not Recommended) Set union for dataset array observations |
unique | (Not Recommended) Unique observations in dataset array |
unstack | (Not Recommended) Unstack dataset array from single variable into multiple variables |
vertcat | (Not Recommended) Vertical concatenation for dataset arrays |
Examples
Tips
To convert numeric arrays, cell arrays, structure arrays, or tables to dataset arrays, you can also use these functions, perspectively:
Dataset arrays can contain built-in types or array objects as variables. Array objects must implement each of these:
Standard MATLAB parenthesis indexing of the form
var(i,...)
, wherei
is a numeric or logical vector corresponding to rows of the variableA
size
method with adim
argumentA
vertcat
method
Version History
Introduced in R2006b
See Also
cell2dataset
| mat2dataset
| struct2dataset
| tdfread
| textscan
| xlsread