Filling in missing data with previous data to perform calculations

3 Ansichten (letzte 30 Tage)
Hi. I have a set of Sp02 data from a 3-day time period that I am using to calculate hypoxic debt. The data is stored in a single array and I am dividing up the array into specific time chunks of different lengths and performing calculations on each chunk of data. In certain sections of each chunk, there are larger sections of erroneous values that I want to fill in with previous non-erroneous values so I can have calculations over the entire duration of the data. I want to replace these sections of bad data with the last previous value before the erroneous data starts, which will change depending on where the section of bad data is located in the array. If there are multiple sections of erroneous values spread out throughout the array of data, how can I extract the last value before the bad data starts and replace the bad data with that single value? **The bad data are values that are equal to 500 or go below 60.
Example: The bad section of data runs from 1 to 500. I have sections of bad data from 10 to 30, 150 to 175, 220 to 240 and 380 to 410. I want to take the values from cell 9, 149, 219, and 379 and put those values in for the bad section i.e. the value in cell 9 would fill in 10 to 30, the value in cell 149 would fill in 150 to 175, and so on.... How would I go about this?
Thank you!

Akzeptierte Antwort

Scott MacKenzie
Scott MacKenzie am 28 Sep. 2021
Since you define bad or erroneous data as values equal to 500 or values less than 60, how about this. Replace the erroneous values with nan and then use the fillmissing function to copy the preceding value into the erroneous positions.
If the data are in a vector d, then
d(d==500) = nan;
d(d<60) = nan;
dnew = fillmissing(d, 'previous');
  3 Kommentare
Muhammad Usman Saleem
Muhammad Usman Saleem am 29 Okt. 2022
whether the results of missingdata will be different when i run it number of times on same missing data sir?
Muhammad Usman Saleem
Muhammad Usman Saleem am 29 Okt. 2022
I think its depends on the technique of interpolation used inside fillmissing function?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interpolating Gridded Data finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by