MATLAB: How to filter/remove peaks in the curve? (not a signal)

filternoisesmooth

Hi all.
I am trying to remove the peaks from my data using the Signal Processing Toolbox, without success.
In my data, which values are attached, there are peaks which values are significantly lower than the "correct data" at the beginning, and afterwards I have peaks with both higher and lower values. Also, there are infinite values which are not plotted and I want to ignore.
I have tried different commands but as I am quite new to MatLab and my curve is not a signal, I am not sure if I am using the ToolBox correctly.
Every help will be very much appreciated. Thank you very much.
P.S. I know the image is from Excel but of course I am managing the data in MatLab.

Best Answer

It is not obvious what result you want. If you just want a regression line through your data, first use the fillmissing (R2016b and later) function to eliminate the non-finite gaps (first replace the Inf values with NaN), then use polyfit and polyval to do a simple regression and evaluation.
I have not looked at your data because I do not know what you want to do. However the best approach to filter design is first to do a Fourier transform (fft) on your data to understand its spectral characteristics, then design your filter to elimiinate the unwanted frequencies. Your data have to be regularly-sampled (constant sampling interval) of none of these will work correctly. If they do not have a constant sampling interval, use the resample function (after fillmissing) first to correct that.