How to find Missing data and insert Nan
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have recorded data for 30 days and and the time interval for recording were 30 minutes which the first 30 minutes of day one is written as 25101.0 and the second 30 mins is 25102.0. The 251 means the 251st day of the year and 01 means the 1st 30 mins of the day. The data missed recording 1-23rd 30 mins of the day, I need to plot a graph and how can I add the missing value and imput NaN so I can analyse it?
0 Kommentare
Antworten (2)
CP
am 30 Apr. 2018
Hi Fengsen,
It's hard to provide a solution without seeing how you have your data vector set-up in MATLAB, but I will try my best to provide you with some guidance.
If you know the indices that do not have data, you can simply write, NaN. For example:
data = [9 4 NaN 6];
time = [1 2 3 4];
plot(time,data,'x')
% Note, that the NaN occurs at the third time entry. Thus, make sure this time entry corresponds
% to the actual time of occurrence using your 25101.0 notation above.
0 Kommentare
dpb
am 30 Apr. 2018
"25101.0 and the second 30 mins is 25102.0."
Then missing points will be where
ix = [diff(t) ~= 1 | diff(t) ~= -23] + 1;
Use those indices to infill the missing locations; note will have to work from rear forward or the index locations will change as the vector length grows.
Alternatively, for each day subsection you can find the subsection length as
ixday=find(diff(fix(t/100))==1);
and any that aren't the multiple of 25 will be short days and then you can interpolate what are found to infill the missing.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!