Fill time series with data coming from other time series.
Mostrar comentarios más antiguos
I have the following matrix:
737044 NaN NaN NaN
737045 NaN NaN NaN
737046 NaN NaN NaN
737047 NaN NaN NaN
737048 NaN NaN NaN
737049 NaN NaN NaN
737050 NaN NaN NaN
737051 NaN NaN NaN
737052 NaN NaN NaN
737053 NaN NaN NaN
In which the first column represents the date (datenum) and the other columns need to be filled with data coming from other time series. Let's say I want to fill the second column of this matrix with the following data, merging the values according to the date:
737045 12.33
737047 15.01
737051 14.77
737052 14.63
737053 13.89
I'm aiming to obtain the following result:
737044 NaN NaN NaN
737045 12.33 NaN NaN
737046 NaN NaN NaN
737047 15.01 NaN NaN
737048 NaN NaN NaN
737049 NaN NaN NaN
737050 NaN NaN NaN
737051 14.77 NaN NaN
737052 14.63 NaN NaN
737053 13.89 NaN NaN
What is the best way to achieve this? How to deal with missing (NaN) values if, for example, I want to perform a regression? Interpolation? Leaving them as they are?
Respuesta aceptada
Más respuestas (1)
Guillaume
el 11 de Mzo. de 2017
The simplest way to do what you want may be to use time tables. It is to synchronise time tables, and you've got a choice of methods for the missing values (fill with missing, fill with nearest, interpolate, etc.).
tt = array2timetable(yourmatrix(:, 2:end), 'RowTimes', datetime(yourmatrix(:, 1), 'ConvertFrom', 'datenum')); %optionally give names to columns with 'VariableNames'
Categorías
Más información sobre Time Series Objects en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!