(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.
dataset
table
ds = table2dataset(t)
example
ds = table2dataset(t) converts a table to a dataset array.
ds
t
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 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 dataset array, returned as a dataset array containing the variables from the input table t.
dataset | table
You have a modified version of this example. Do you want to open this example with your edits?