categorizing tables after reading them.

조회 수: 4(최근 30일)
MA
MA 2021년 10월 15일
답변: Prachi Kulkarni 2021년 10월 18일
assuming we are reading some data files in matlab as tables, how can we create groups or categorizes that would classify the tables according to the ''HOUR'' value they are containing?
for ex: we want to have 6 bins or categorizes for all the data we have, as we divide the 24hr into 3hrs interval. so we would like to have the tables that their hour value is betweeen 0-3 in one group, and the tables their hour value between 4-7 in another group, tables with hours betweeen 8-11 in another group and so on.. for the all 24hrs.
assuming that each data file or (table) contains data for some interval of time how can we categorize each indiviual table and then all the tables?
thanks for looking at it,

답변(1개)

Prachi Kulkarni
Prachi Kulkarni 2021년 10월 18일
Hi,
If you initially have all the data in a table T and HOUR is one the variables in table T, you can create separate tables depending upon the categorization of HOUR as follows.
T1 = T(T.HOUR>=0 & T.HOUR<=3,:);
T2 = T(T.HOUR>=4 & T.HOUR<=7,:);
T3 = T(T.HOUR>=8 & T.HOUR<=11,:);
T4 = T(T.HOUR>=12 & T.HOUR<=15,:);
T5 = T(T.HOUR>=16 & T.HOUR<=19,:);T6 = T(T.HOUR>=20 & T.HOUR<24,:);

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by