Find and fill in missing records/data/lines/rows from array

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
01/01/2019 01:00 D2 MS2 MGD2 MGS2
....
MISSING MISSING MISSING MISSING MISSING
....
31/12/2019 22:00 D8759 MS8759 MGD8759 MGS8759
31/12/2019 23:00 D8760 MS8760 MGD8760 MG8760
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 taking an average of the values above and below 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)

Cris LaPierre
Cris LaPierre on 28 Feb 2021
There's not enough details to be able to provide a solution, but take a look at the following functions
  2 Comments
Cris LaPierre
Cris LaPierre on 28 Feb 2021
Edited: Cris LaPierre on 28 Feb 2021
Still no specifics, so I can only point you to possible functions to look into. It sounds like you might benefit from converting your data to a timetable and then use the retime function. This will allow you to specify a desired time vector for your table, and then specify a method to use the existing data to determine the values of the new time steps.
Perhaps this example will help.

Sign in to comment.

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by