필터 지우기
필터 지우기

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