How to extrapolate data with NaN data series?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Chunru
le 30 Oct 2021
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Time Series dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!