Calculating mean of signal between certain time interval in a loop.
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
BHARAT SINGH RAWAT
am 23 Apr. 2022
Bearbeitet: Star Strider
am 23 Apr. 2022
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.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 23 Apr. 2022
Bearbeitet: Star Strider
am 23 Apr. 2022
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
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.
.
0 Kommentare
Weitere Antworten (1)
Jan
am 23 Apr. 2022
Use findchangepts to determine the constant time phase. Then calculate the mean.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!