Inserting missing rows to table for interpolation

3 visualizaciones (últimos 30 días)
Sebastian Rehorst
Sebastian Rehorst el 27 de Mzo. de 2023
Respondida: Peter Perkins el 27 de Mzo. de 2023
Hello everyone,
I am trying to interpolate data with normally 25 data rows representing 25 data point times. I have 489 subtables and not every every table consists of 25 data rows. Now i want to insert rows of NaN into the subtables at specific rows. So that I can later interpolate the data by inserting the missing points.
For example: In subtable{3,1} are missing data point times of 6 an 10 and i want to insert a row of NaN at row 6 and row 10 while not overwriting the other values.
I tried creating 489 NaN-tables of 25x18 values with [:,1:17]=NaN and [:,18]=datatimepoints. Datatimepoints=[1;2;3;4;5;...;25]. Then I tried to write the subtable data into the NaN-tables in the corresponding rows. Here is the code:
for i=1:489
NaN_Table{i,1}= NaN(25:18);
VarNames = subTables{1,1}.Properties;
NaN_Table{i,1}.Properties = VarNames;
for j=1:25
for i=1:489
x = table2array(subTables_{i,1}(j,18));
y = table2array(NaN_Table{i,1}(j,18));
if x == y
NaN_Table{i,1}(y,:) = subTables{i,1}(j,1:18);
Error using ()
Row index exceeds table dimensions.
Error in prostudy (line 82)
x = table2array(subTables{i,1}(j,18));
Makes sense to me bc some subTables do not have 25 rows of data. But I dont know how to extend the subtable data to 25 rows, bc they are different categories of datatypes (e.g. cell, categorical, datetime, double).

Respuestas (1)

Peter Perkins
Peter Perkins el 27 de Mzo. de 2023
I'm not sure I follow your question, but it's almost certain that using timetables (maybe with durations as the row times) and synchronize or retime will solve it.


Más información sobre Interpolation en Help Center y File Exchange.




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by