how to add missing months in loop?

1 view (last 30 days)
SONI SONI
SONI SONI on 18 Feb 2015
Edited: Stephen23 on 18 Feb 2015
I have a monthly soil moisture data of 10 year in hdf format. The data file contains 105 hdf file, 15 months are missing. The dimension of matrix is 180*360 now I want to create this matrix in 180*360*120. How could I add missing months in a loop.
  2 Comments
Stephen23
Stephen23 on 18 Feb 2015
Edited: Stephen23 on 18 Feb 2015
Your question is not clear: Do you want to interpolate your data for the missing dates, or just complete the list of dates so that there are none missing?
SONI SONI
SONI SONI on 18 Feb 2015
I repeat my question..... I have global soil moisture data of 105 months (15 months missing out of 10 year). Dimension of data is 180*360 and format is hdf. Now I need to infile all the data (105) and then want add 15 missing months. so finally dimension of result will be 180*360*120 that will show a complete time series of 10 year.

Sign in to comment.

Answers (1)

Stephen23
Stephen23 on 18 Feb 2015
Edited: Stephen23 on 18 Feb 2015
Use one of the interpolation tools , filling in missing data is exactly what they can do. Which tool you select depends on the shape of your data, and your own requirements for the "filling" in of the data. For a start, try interp1 .
Note that you can interpolate all of the data at once, without loops, by using the matrix input of most of these functions, eg for interp1: If you have multiple sets of data that are sampled at the same point coordinates, then you can pass v as an array. Each column of array v contains a different set of 1-D sample values.
Note that interpolation does not require any loops, even though you put this in the question title.

Community Treasure Hunt

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

Start Hunting!