How to concatenate time traces and fill up missing data?

9 views (last 30 days)
Hello all,
I have a problem concerning concatenation of contiguous data with little gaps in it and am trying to find a workaround. I have several data that are stored as n x 2 arrays in the matlab workspace that I want to combine to one n x 2 array. The data come from electrophysiological recordings, the first columns contain time in seconds and the second current in Ampere. They are stored in different traces that all come from an almost contiguous recording. I want to concatenate these traces to store them all in one vector to export them for further analysis in a different program which is able to read in a simple text file.
Now my problem is that the concatenated vector contains little gaps which make further analysis impossible. My recording has a continuous sampling rate of 25kHz and I would like to fill in the gaps with the same sampling rate. The value in the second column can easily be any constant as I only need to create a vector of contiguous data.
I looked in the documentation and only found some possibility in simulink, but is there any ideas on a solution for this problem in matlab? My only idea so far would be creating a loop that creates a vector containing the missing values. Is there any better solution? I'm also happy about a link to the documentation of the functions I need for this as I couldn't find the right ones!

Answers (1)

Nipun Katyal
Nipun Katyal on 16 Aug 2020
The problem mentioned above can be tackled using fillmissing function all you to do is generate a time vector according to your sampling rate, fill the current values if they are in one of your nX2 arrays otherwise fill it with Nan. With the help of this function you can fill those values either to the nearest value or one of the other options there exist.


Find more on Creating and Concatenating Matrices in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!