Creating n number of tables using already present table in matlab
조회 수: 1 (최근 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.
댓글 수: 0
답변 (3개)
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
댓글 수: 0
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.
댓글 수: 0
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!