How to find Missing data and insert Nan
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (2개)
CP
2018년 4월 30일
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
dpb
2018년 4월 30일
"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
참고 항목
카테고리
Help Center 및 File Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!