Creating n number of tables using already present table in matlab
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to create n number of tables based on a main table that I have. I want to create this micro tables on column conditions from main table.
First micro table will be between adjacent 0 speed(column) and odometer(first to last of micro table) condition of greater than 0km.
I want to generated yellow tables as shown in attachment.
0 commentaires
Réponses (3)
Nitin Kapgate
le 14 Déc 2020
You can refer to the following code snippet to learn about extracting sub-tables based on conditions on the data in columns of main table:
% Create a table by reading all columns from the file, patients.dat.
T = readtable('patients.dat');
T(1:5,:)
% View the data type, description, units, and other descriptive statistics
% for each variable by creating a table summary using the summary function.
summary(T) % A table with 100 rows
% Get a sub-table based on conditions on columns
T_New = T((T.Height > 67) & (T.Weight > 142.5), :);
summary(T_New) % A sub-table with 40 rows
0 commentaires
Eric Sofen
le 14 Déc 2020
I would advise that in many cases, you're better off adding a grouping variable based on the conditions you described and doing grouped calculations (using groupsummary, varfun, or findgroups/splitapply) rather than splitting your table into a bunch of separate workspace variables. Once you've got a bunch of subtables with different names in your workspace, they become hard to iterate over compared to one table with a grouping variable.
0 commentaires
Ali Sarab
le 30 Juin 2021
How to create n tables from one tables by categories in for loop
for ii=1:n
names of tables=???
end
how to assigned automatic naming based on the grouping variable
unstack command in matlab create one table grouped
0 commentaires
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!