Interpolating data from missing timesteps.
Afficher commentaires plus anciens
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!
Réponse acceptée
Plus de réponses (1)
Andrew Newell
le 23 Avr 2011
0 votes
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?
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!