Inserting missing rows to table for interpolation

2 visualizaciones (últimos 30 días)
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:
NaN_Table=[];
for i=1:489
NaN_Table{i,1}= NaN(25:18);
NaN_Table{i,1}(:,18)=[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25];
NaN_Table{i,1}=array2table(NaN_Table{i,1});
VarNames = subTables{1,1}.Properties;
NaN_Table{i,1}.Properties = VarNames;
end
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);
end
end
end
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).
0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Respuestas (1)

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.
0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Categorías

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

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by