Creating n number of tables using already present table in matlab

3 次查看(过去 30 天)
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.

回答(3 个)

Nitin Kapgate
Nitin Kapgate 2020-12-14
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
Refer the link to learn more about tables.

Eric Sofen
Eric Sofen 2020-12-14
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.

Ali Sarab
Ali Sarab 2021-6-30
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

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by