MATLAB Answers

AA
0

How to fill a data table with gaps

Asked by AA
on 4 Apr 2018
Latest activity Answered by Walter Roberson
on 4 Apr 2018
Hi, I have got this data table with the following values: As you can see from the table below that there are gaps in the second column. For instance, 109, 110, 111, 112 are missing. At the same time, 120 is also missing. This table has 1000 rows and I have only shown a fraction of the table. Is there a way I can fill the table automatically in such a way that the gaps are filled the values from the columns 3,4,5 and 6 one row above? Thanks for the help.
732315 108 1.9193000 1.9193000 1.9193000 1.9193000
732315 113 1.9193000 1.9193000 1.9060000 1.9060000
732315 114 1.9058000 1.9058000 1.9058000 1.9058000
732315 115 1.9060000 1.9061000 1.9060000 1.9060000
732315 116 1.9061000 1.9065000 1.9060000 1.9064000
732315 117 1.9065000 1.9067000 1.9062001 1.9067000
732315 118 1.9066000 1.9072000 1.9066000 1.9072000
732315 119 1.9071000 1.9076999 1.9065000 1.9074000
732315 121 1.9075000 1.9079000 1.9074000 1.9076999
732315 122 1.9080000 1.9080000 1.9068000 1.9078000
732315 123 1.9076999 1.9079000 1.9076999 1.9079000
732315 124 1.9078000 1.9079000 1.9076000 1.9076999

  0 Comments

Sign in to comment.

1 Answer

Answer by Walter Roberson
on 4 Apr 2018
 Accepted Answer

Convert your data to a timetable() and use fillmissing() with an appropriate method such as 'previous' or possibly 'linear'

  0 Comments

Sign in to comment.