Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

table2dataset

Convert table to dataset array

The dataset data type might be removed in a future release. To work with heterogeneous data, use the MATLAB® table data type instead. See MATLAB table documentation for more information.

Syntax

ds = table2dataset(t)

Description

example

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

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 =

  5x3 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.

See Also

|

Topics

Introduced in R2013b

Was this topic helpful?