How to smooth a curve to the lower bound in Matlab

조회 수: 4 (최근 30일)
Sachin Hegde
Sachin Hegde 2023년 4월 27일
댓글: Sachin Hegde 2023년 7월 25일
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

채택된 답변

Mathieu NOE
Mathieu NOE 2023년 5월 30일
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
Mathieu NOE
Mathieu NOE 2023년 6월 28일
Hello
Problem solved ?
Sachin Hegde
Sachin Hegde 2023년 7월 25일
Yes!. Thank you. I am extremely sorry for the delayed response.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Adithya
Adithya 2023년 4월 27일
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.

카테고리

Help CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by