Finding upper and lower (min and max) states
2 ビュー (過去 30 日間)
古いコメントを表示
I have signals which contaiin multiple pulses which somewhat vary from each other. I am calculating the upper(max) and lower(min) states of each pulse in order to calculate rise and fall time for each indivisual pulse. As i have only the basic matlab with me ,i cannot make use of the functions risetime, statelevels which would calculate the required accurately , so proceeding mathematically.
2 件のコメント
回答 (1 件)
Star Strider
2020 年 4 月 13 日
The 'movmedian' method works as well as 'sgolay', and appears to produce essentially the same result. It is a core MATLAB function introduced in R2016a. You should have it.
There is nothing in the documentation that says the 'sgolay' method requires the Signal Processing Toolbox, so I assumed it was implemented independently.
T = readtable('data.xlsx');
T.Var3 = smoothdata(T.Var2, 'movmedian', 3000);
[Lc,m,b] = ischange(T.Var3, 'linear', 'Threshold',5);
Cix = find(Lc);
Ic = [Cix m(Cix) b(Cix) T.Var1(Cix,:) T.Var2(Cix,:)]; % Consolidation Matrix
risetime = Ic(2:4:end,4) - Ic(1:4:end,4);
falltime = Ic(4:4:end,4) - Ic(3:4:end,4);
statelo = Ic(1:4:end,5);
statehi = Ic(3:4:end,5);
figure
plot(T.Var1, T.Var2)
hold on
plot(T.Var1, T.Var3, '-r')
plot(T.Var1(Cix), T.Var3(Cix), 'pg', 'MarkerFaceColor','g')
hold off
grid
legend('Original Data', 'Smoothed Data', 'Change Points', 'Location','E')
The smoothing method is all that is changed here. Experiment with the window length in the smoothdata call (3000 in my code) to get different results. (I am using R2020a.)
.
4 件のコメント
Star Strider
2020 年 4 月 14 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!