Select only January and April months among 30 years monthly data (how to filter?)

1 次查看(过去 30 天)
Hey all,
I have a cell (1 x 92) which includes 92 tables . In each table I have a column named dates. I want to filter the whole table based on January and April. I wish if it is possible have the value of January and April as 2 column after all existing column in each table (cell array), for example:
Thank you so much
  6 个评论
Walter Roberson
Walter Roberson 2020-3-29
jan_rrr24 and april_rrr24 are already the extracted rrr24 values for the respective months.
You cannot construct a table that contains both jan_rrr24 and april_rrr24 entries because there are a different number of days in January (31) than in April (30) so you will not have the same number of rows for the two.
nCELL = numel(CELL);
newCELL = cell(nCELL, 2);
for i=1:nCELL
date_month = month(CELL{i}.dates);
jan_mask = date_month == 1;
april_mask = date_month == 4;
jan_rrr24 = CELL{i}.rrr24(jan_mask);
april_rrr24 = CELL{i}.rrr24(april_mask);
newCELL{i,1} = jan_rrr24;
newCELL{i,2} = april_rrr24;
end

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by