필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
BN
BN 2020년 3월 29일
댓글: BN 2020년 3월 29일
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