Calculating mean of signal between certain time interval in a loop.

11 ビュー (過去 30 日間)
BHARAT SINGH RAWAT
BHARAT SINGH RAWAT 2022 年 4 月 23 日
編集済み: Star Strider 2022 年 4 月 23 日
I want to calculate the mean of such signals where for the time interval where the signal value is almost constant.(for ex between t=20 and t=23 for the file namde MatlabCode).However when I have multiple files in loop the start point of each signal is not always the same.How can I code so that the mean signal is always calculated for each file between the time intervals where the signal is almost stable(i.e constant).I have attached signals from two different files for reference.

採用された回答

Star Strider
Star Strider 2022 年 4 月 23 日
編集済み: Star Strider 2022 年 4 月 23 日
It is not possible to do anything with an image of data.
Simulating it —
t = linspace(0, 20);
s = ((1 - exp(-1.5*t)) + 0.5*t).*(t<=10) + (0.15*exp(-1.75*(t-12))).*(t>10); % Simulate Missing Signal
dsdt = gradient(s) ./ gradient(t);
Lv1 = dsdt>0; % Positive Derivative Values
fls = min(dsdt(Lv1)) % Derivative Minimum
fls = 0.5000
tol = 1E-2;
Lv2 = abs(dsdt(Lv1) - fls) <= tol; % Minimum Region With Tolerance
figure
plot(t, s)
hold on
plot(t, dsdt)
plot(t(Lv2), dsdt(Lv2), '+g')
plot(t(Lv2), s(Lv2), '+g')
hold off
grid
legend('Signal','Derivative','Constant Slope Section', 'Location','best')
This illustrates the way I would approach it, to define the relatively constant slope region. (The mean may not be appropriate for a relatively linearly increasing part of the signal, and a linear fit might be more appropriate.)
Experiment to get different results.
EDIT — (23 Apr 2022 at 17:10)
Changed ‘tol’ value to include a longer section of the selected curve.
.

その他の回答 (1 件)

Jan
Jan 2022 年 4 月 23 日
Use findchangepts to determine the constant time phase. Then calculate the mean.

カテゴリ

Help Center および File ExchangeSmoothing and Denoising についてさらに検索

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by