필터 지우기
필터 지우기

remove selected months and years

조회 수: 2 (최근 30일)
akk
akk 2019년 7월 26일
편집: Adam Danz 2019년 7월 26일
Hi,
I am trying to create a matrix where I have removed selected months and years. Here is what I have so far:
dv=datevec(date); %where dv(:,1)=year, dv(:,2)=month and dv(:,3)=day
How do I remove summer of 2009 (i.e., dv(:,1)=2009, dv(:,2)=7 and dv(:,2)=8) and create a new dv?
Thanks!

채택된 답변

Adam Danz
Adam Danz 2019년 7월 26일
편집: Adam Danz 2019년 7월 26일
idx = dv(:,1) == 2019 & ismember(dv(:,2),[6,7,8]);
dv2 = dv(~idx,:); % to create a new dv
dv(idx,:) = []; % to remove from existing dv
  댓글 수: 3
akk
akk 2019년 7월 26일
Ah yes. I was just about to ask about your answer until you edited it. This makes more sense. Thanks!
Adam Danz
Adam Danz 2019년 7월 26일
편집: Adam Danz 2019년 7월 26일
Yeah, I switched the last two lines in case they were both run on the same dv vector. Those two lines are two options to choose from.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by