Fill in missing data, unrecorded values, multiple columns

3 views (last 30 days)
Hi there, I have 5 year long datasets, each should be 8760 rows long(the no. hours in a non-leap year), but the datasets are not consistent, they are 8752, 8731, 8757, 8760, 8759 long. Obviously, at some hours the data was not recorded at all, and are completely missing at random points in my file.
The Colums Headers are seen below. D1,MS1 etc. representing the 1st row of data values
ob_end_time Direction MeanSpeed MaxGustDirection MaxGustSpeed MaxGustTime
01/01/2019 00:00 D1 MS1 MGD1 MGS1 MGT1
01/01/2019 01:00 D2 MS2 MGD2 MGS2 MGT2
31/12/2019 22:00 D8759 MS8759 MGD8759 MGS8759 MGT8759
31/12/2019 23:00 D8760 MS8760 MGD8760 MG8760 MGT8760
How do I go about finding where the missing data records are and then filling the missing rows with the correct time, so each year has 8760 values? e.g. if 03/03/2019 was non-existant, to create a new row there, fill in the missing date, and then the other missing parameters?
How would I also go about filling in the missing values for the other columns(I assume linear interpolation would work?
I am somewhat new to matlab and this is all I need help with. I appreciate any help you can give, thanks.

Answers (1)

dpb on 28 Feb 2021
"am somewhat new to matlab and this is all I need help with..."
In that case, you're doing well indeed! Congratulations!!! :)
TMW has just the tool already built for you -- see <fillmissing>. I'd recommend reading up on the auxiliary information on timetables in general; you'll be certain to find a lot of use going forward for rowfun, retime and friends...


Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by