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

14 ビュー (過去 30 日間)
한 박 2024 年 5 月 26 日 14:47
コメント済み: Star Strider 2024 年 5 月 27 日 11:00
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?

サインインしてコメントする。

採用された回答

Star Strider 2024 年 5 月 26 日 15:35
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 日 5:47
thank you :)
Star Strider 2024 年 5 月 27 日 11:00
As always, my pleasure!

サインインしてコメントする。

その他の回答 (1 件)

William Rose 2024 年 5 月 26 日 18:47
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 Center および File ExchangeSmoothing and Denoising についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by