How to smooth a curve to the lower bound in Matlab
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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')
更多回答(1 个)
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.
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!