Remove evenly distributed spikes from curve

2 visualizaciones (últimos 30 días)
Jan Heinsoth
Jan Heinsoth el 27 de Abr. de 2021
Comentada: Star Strider el 29 de Abr. de 2021
Hi, I got some data from the lab giving the height data of holes in a sample I put under a microscope, so I could get a profile of the sample. Since I expect regularly occurring holes in the sample i tried to find the places with the steepest slope, by maxima and minima of the gradient of the data. I found that the gradient curve has many evenly distributed spikes on top of a function that is otherwise really good looking. I tried a smoothing spline to get rid of the spikes, but it also replicates them. I'll give you my code and the graph below. Please help me to get rid of those spikes. Thanks in advance.
% reading in the data from the file
calib5 = importdata(['C:\Users\jan\OneDrive - Carl von Ossietzky Univers',...
'ität Oldenburg\UniShit\Engineering Physics\Semester III - winter 20',...
'20-2021\Laboratory Project I\Data from the Lab\5_100x_zStapelBericht.xlsx']);
% calculating the gradient
c5_1_dDx = gradient(calib5.data.Profil1(:,2))./gradient(calib5.data.Profil1(:,1));
hold on
% creation of the plot above
plot(calib5.data.Profil1(:,1),sum([[diff(calib5.data.Profil1(:,2));0],...
[0;diff(calib5.data.Profil1(:,2))]],2)) % plot of the gradient replicated using diff()
plot(calib5.data.Profil1(:,1),c5_1_dDx) % plot of the gradient
hold off
PS: I really need to find the prominent local maxima and minima of this and not just the spikes.
  4 comentarios
Jonas
Jonas el 27 de Abr. de 2021
Editada: Jonas el 27 de Abr. de 2021
maybe a moving median is also a good alternative, looks like the peaks you want to remove are only one sample long, so you can try a moving median with a window length of 3
Rik
Rik el 29 de Abr. de 2021
Comment posted as flag by @Jan Heinsoth:
The proposed lowpass worked as well.

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 27 de Abr. de 2021
See if the filloutliers function will do what you want.
  2 comentarios
Jan Heinsoth
Jan Heinsoth el 29 de Abr. de 2021
Editada: Jan Heinsoth el 29 de Abr. de 2021
Thank you, It did not perfectly smooth the signal, but now it is smooth enough for my purposes.
But the lowpass filter proposed by @Jonas did also work for me.
Star Strider
Star Strider el 29 de Abr. de 2021
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by