How to smooth a curve to the lower bound in Matlab

4 Ansichten (letzte 30 Tage)
Sachin Hegde
Sachin Hegde am 27 Apr. 2023
Kommentiert: Sachin Hegde am 25 Jul. 2023
Hi, I have noisy data with some peaks. I want to smoothen the curve but not with a mean. I want to filter to the lower part of the curve. How can i do this? Thank you in advance

Akzeptierte Antwort

Mathieu NOE
Mathieu NOE am 30 Mai 2023
hello
smoothn was done for you ! use the 'robust' option to get rid of the outliers
here a demo
x = linspace(0,100,200);
y = cos(x/10)+(x/50).^2 + randn(size(x))/10;
% some very noisy y points (outliers)
ind = randi(100,25,1);
y(ind) = y(ind)+1;
z = smoothn(y); % Regular smoothing
zr = smoothn(y,'robust'); % Robust smoothing
plot(x,y,'r.-',x,z,'k',x,zr,'g','LineWidth',2)
title('Regular vs Robust smoothing')
legend('Raw data','Regular smoothing','Robust smoothing')
  2 Kommentare
Mathieu NOE
Mathieu NOE am 28 Jun. 2023
Hello
Problem solved ?
Sachin Hegde
Sachin Hegde am 25 Jul. 2023
Yes!. Thank you. I am extremely sorry for the delayed response.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Adithya
Adithya am 27 Apr. 2023
One way to filter the lower part of the curve is by using a low-pass filter. A low-pass filter can be used to remove high-frequency noise while preserving the lower-frequency components of the signal.
One common type of low-pass filter is the moving average filter, which can be used to smooth out a signal by averaging the values over a window of neighboring data points. However, as you mentioned, this may not be the best option for your case.
Instead, you could use a median filter, which replaces each data point with the median of the neighboring data points within a window. This can be effective in reducing the influence of outlier data points, such as the peaks you mentioned, while preserving the general shape of the curve.
Another option is to use a Gaussian filter, which convolves the signal with a Gaussian kernel, effectively smoothing out the signal while preserving its overall shape. You can adjust the width of the Gaussian kernel to control the amount of smoothing.
In summary, to filter the lower part of the curve, you can try using a median filter or a Gaussian filter, which can help reduce the influence of outlier data points while preserving the overall shape of the signal.

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by