How to extrapolate data with NaN data series?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tyann Hardyn
am 30 Okt. 2021
Beantwortet: Chunru
am 30 Okt. 2021
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 Kommentare
Akzeptierte Antwort
Chunru
am 30 Okt. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Time Series 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!