Interpolating data from missing timesteps.
이전 댓글 표시
I have 92 days of meteorological data with 4 samples per day, thus I should have 368 time steps. However, I currently only have 364 steps because one of the days in the middle of the sample is missing. The data is going to be used to condition another model so I need to have some kind of slightly reasonable data in the gap rather than NaN or 'O'.
The code that I'm trying to use is below, with the intention of creating a new array called 'PRECIP' extracting all of the data that I already have in 'PRECIP_CS' and inserting it into the correct place in the new array. The missing data should fit between step 156 and 157.
PRECIP = zeros(46,28,368);
for t=1:156
PRECIP(:,:,t) = PRECIP_CS(:,:,t);
end
for t=161:368
PRECIP(:,:,t) = PRECIP_CS(:,:,t-4);
end
t1=156;
t2=161;
for t=1:6;
for t3=t1:t2;
xt = t1:1:t2;
int1(:,:,t) = interp1(PRECIP_CS(:,:,t3),xt);
end
end
Currently the interpolant creates a new array that is 6x28x157 rather than 46x28x6 that I was hoping for. In addition the new array consists of NaN for the first 6 time steps and 0 for the rest. I know I must be doing something relatively simple wrong, I just can't work out what. Any assistance would be very welcome!
채택된 답변
추가 답변 (1개)
Andrew Newell
2011년 4월 23일
0 개 추천
This is Andrew's wife. I prefer to collapse the data gap, do the operation, then re-nanfill the data gap. (I do this when calculating an empirical orthogonal function using a gappy two dimensional data array). If you temporarily removed that one day of data, would your model work?
카테고리
도움말 센터 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!