MATLAB: Find duration of signal

indexingMATLABsignal processing

I have a set of signals that due to some unknown error have been acquired with millions of empty datapoints. Is there a way I can automatically detect the moment the signal ends so I can delete everything from that point onwards?
Thanks everyone.

Best Answer

  • Something like this may work for you
    Raw data:
    data = readmatrix('sampledata.csv');
    avgdat = movmean(abs(data), 5);
    threshold = 0.01;
    data(avgdat < threshold) = [];
    plot(data)