Main Content

table2dataset

(Not Recommended) Convert table to dataset array

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

ds = table2dataset(t) converts a table to a dataset array.

example

Examples

collapse all

Load the sample data, which contains nutritional information for 77 cereals.

load cereal;

Create a table containing the calorie, protein, fat, and name data for the first five cereals. Label the variables.

Calories = Calories(1:5);
Protein = Protein(1:5);
Fat = Fat(1:5);
Name = Name(1:5);

cereal = table(Calories,Protein,Fat,'RowNames',Name)
cereal=5×3 table
                                 Calories    Protein    Fat
                                 ________    _______    ___

    100% Bran                       70          4        1 
    100% Natural Bran              120          3        5 
    All-Bran                        70          4        1 
    All-Bran with Extra Fiber       50          4        0 
    Almond Delight                 110          2        2 

Convert the table to a dataset array.

ds = table2dataset(cereal)
ds = 
                                 Calories    Protein    Fat
    100% Bran                     70         4          1  
    100% Natural Bran            120         3          5  
    All-Bran                      70         4          1  
    All-Bran with Extra Fiber     50         4          0  
    Almond Delight               110         2          2  

Input Arguments

collapse all

Input table to convert to a dataset array, specified as a table. Each variable in t becomes a variable in the output dataset array ds.

Data Types: table

Output Arguments

collapse all

Output dataset array, returned as a dataset array containing the variables from the input table t.

Version History

Introduced in R2013b

See Also

|

Topics