From the following:
t = transpose(1/24:1/24:40);data1 = 1+(30-1).*rand(length(t),1);Randm = floor(1+(length(t)-1).*rand(37,1));data1(Randm) = nan;plot(t,data1);
We can see that the vector contains some missing values i.e. nan. The data shows the variation in a certain variable for 40 days i.e. there are 40 24 hours in the vector. How could I replace the missing values with the average for that particular 24 hour, in addition, if 24 consecutive values were missing i.e. no values for an entire day, how would I replace those missing values with the average for that week i.e. from the previous 7 days? I'm thinking of applying this with a moving window, would this be the best method?
Best Answer