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

7 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Annotations 的更多信息

产品


版本

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by