필터 지우기
필터 지우기

Fill vector with missing values

조회 수: 3 (최근 30일)
hdiba
hdiba 2016년 7월 20일
댓글: Andrei Bobrov 2016년 7월 20일
Hello, i have vectors that represent the day-,month and year values.As you can see in the example below, the day an month vectors do not start with 1, what would be 1. Januar. The vector also dont end with 31 and 12, what would be 31. December. Does anyone have any suggestion how i can first check what is the starting value of day and month and thenn fill the missing valuse, so i have a complete year? thanks a lot!
Day: Month: Year:
6 8 1993
7 8 1993
8 8 1993
9 8 1993
. . .
. . .
. . .
3 11 1993

채택된 답변

Andrei Bobrov
Andrei Bobrov 2016년 7월 20일
yyear = [Year,Month,Day];
y1 = datevec(datenum([Year(1) 1 1]):datenum([Year(1) 12 31]));
y1 = y1(:,1:3);
missing_values = y1(~ismember(y1,yyear,'rows'),:);
  댓글 수: 2
hdiba
hdiba 2016년 7월 20일
Thanks a lot. I have another variable with entries for the days, for example: measurement of rainfall on every day.. now that i've filled the missing dates, i would like to add zero values for the rainfall for the added dates? can u help?
Andrei Bobrov
Andrei Bobrov 2016년 7월 20일
yourdata = [Year,Month,Day,rainfall];% rainfall - vector with data of rainfall
y1 = datevec(datenum([Year(1) 1 1]):datenum([Year(1) 12 31]));
y1 = y1(:,1:3);
t = ismember(y1,yourdata(:,1:3),'rows');
out = [y1,zeros(size(y1,1),1)];
out(t,4) = yourdata(:,end);

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by