Smoothing or special techniques to resolve uncertain peaks are required!!

조회 수: 4 (최근 30일)
I need to find the local extremum point in this data and The photo above shows the data where we found the maxima.
However, the peaks have an irregular pattern. How can I make this data as smooth as a sin function?
Nothing like LPF or moving average filters helped me, please help me out

채택된 답변

Star Strider
Star Strider 2024년 5월 26일
If you want to make it smooth, there are a few options. One of course is to calculate the Fourier transform, choose a suitable cutoff frequency from that information, and then use either the lowpass or bandpass functions to filter it. For best reulsts, use the name-value pair 'ImpulseResponse','iir' with those.
A second option is to use the Savitzky-Golay filter (sgolayfilt) function. I usually use a 3-degree polynomial,, and then vary the ‘framelen’ value to get the result I want.
If you are simply concerned about getting the ‘correct’ peak values and locations without the nearby additional peaks, an easier option is to use 'MinPeakDistance' with findpeaks or 'MinSeparation' with islocalmax.
All signal processing is somewhat interactive, and most techniques require some experimentation to get the desired result.
  댓글 수: 2
한 박
한 박 2024년 5월 27일
It was very helpful you mentioned about name-value pair with findpeaks
thank you :)

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

추가 답변 (1개)

William Rose
William Rose 2024년 5월 26일
You ask "how can I make this data as smooth as a sin function?".
You could fit the data with a sinusoid. Here is an example.
xdata=0:100;
s=4; % amplitude of noise added to sinusoid
ydata=10*sin(0.3*xdata)+5+s*(rand(1,101)-.5); % noisy sine wave
% Define function
fun = @(p,x)p(1)*sin(p(2)*x+p(3))+p(4);
% p(1)=amplitude, p(2)=frequency, p(3)=phase, p(4)=offset
% Find parameters that give best fit
% p0=initial guess for parameters
r=zerocrossrate(ydata-mean(ydata)); % zero crossing rate
p0=[(max(ydata)-min(ydata))/2,r*pi,mean(ydata),0];
lb=[.1,.01,0,-50]; % lower bounds for parameters
ub=[100,10,2*pi,50]; % upper bounds for parameters
p = lsqcurvefit(fun,p0,xdata,ydata,lb,ub)
Local minimum possible. lsqcurvefit stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
p = 1x4
10.2101 0.2998 6.2832 5.0292
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% compute the fitted curve
yfit=fun(p,xdata);
% plot result
figure; plot(xdata,ydata,'r*',xdata,yfit,'-r');
The maximum values of this fitted function are all the same. The maximum values of this fitted function are p(1)+p(4). You could make a different fitting function.

카테고리

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