How to extrapolate data with NaN data series?
4 次查看(过去 30 天)
显示 更早的评论
Hi, everyone
I want to ask about how to extrapolate a data series with NaN in the data. So i have a data series like this :
magnetH = [21340; 21340; 21340; 21341; 21341; NaN; NaN; 21340; NaN; NaN]
time_series = [1978-03-29 00:00:00; 1978-03-29 00:01:00; 1978-03-29 00:02:00; 1978-03-29 00:03:00
1978-03-29 00:04:00; 1978-03-29 00:05:00; 1978-03-29 00:06:00; 1978-03-29 00:07:00
1978-03-29 00:08:00; 1978-03-29 00:09:00]
extrapolat_time = [1978-03-29 00:00:00; 1978-03-29 00:01:00; 1978-03-29 00:02:00; 1978-03-29 00:03:00
1978-03-29 00:04:00; 1978-03-29 00:05:00; 1978-03-29 00:06:00; 1978-03-29 00:07:00
1978-03-29 00:08:00; 1978-03-29 00:09:00; 1978-03-29 00:10:00; 1978-03-29 00:11:00
1978-03-29 00:12:00; 1978-03-29 00:13:00; 1978-03-29 00:14:00; 1978-03-29 00:15:00
1978-03-29 00:16:00; 1978-03-29 00:17:00; 1978-03-29 00:18:00; 1978-03-29 00:19:00]
The time series data is a combination between datetime and duration data (yyyy-MM-dd hh:mm:ss) with 1 minute of space between each data. Now, i want to extrapolate the data of magnetH to be defined at extrapolat_time data series....
Would it be possible anyone? Thanks for your help and cooperation.... Iam very grateful, if someone can solve my problem...
/.\ /.\ /.\
0 个评论
采纳的回答
Chunru
2021-10-30
magnetH = [21340; 21340; 21340; 21341; 21341; NaN; NaN; 21340; NaN; NaN];
% The original time_series statement are invalid
time_series = ["1978-03-29 00:00:00"; "1978-03-29 00:01:00"; "1978-03-29 00:02:00"; "1978-03-29 00:03:00"; ...
"1978-03-29 00:04:00"; "1978-03-29 00:05:00"; "1978-03-29 00:06:00"; "1978-03-29 00:07:00"; ...
"1978-03-29 00:08:00"; "1978-03-29 00:09:00"];
t = datetime(time_series, "Format", "yyyy-MM-dd HH:mm:ss")
% extrapolat_time = [1978-03-29 00:00:00; 1978-03-29 00:01:00; 1978-03-29 00:02:00; 1978-03-29 00:03:00
% 1978-03-29 00:04:00; 1978-03-29 00:05:00; 1978-03-29 00:06:00; 1978-03-29 00:07:00
% 1978-03-29 00:08:00; 1978-03-29 00:09:00; 1978-03-29 00:10:00; 1978-03-29 00:11:00
% 1978-03-29 00:12:00; 1978-03-29 00:13:00; 1978-03-29 00:14:00; 1978-03-29 00:15:00
% 1978-03-29 00:16:00; 1978-03-29 00:17:00; 1978-03-29 00:18:00; 1978-03-29 00:19:00]
ti = t(1) + (0:19)'/(24);
% using fillmissing to replace the nans.
magnetHi = interp1(t, fillmissing(magnetH, 'linear'), ti, 'linear', 'extrap')
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Time Series 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!