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.

回答(1 个)

Star Strider
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 个评论
SHANTANU KSHIRSAGAR
Yes I do not have the toolboxes on the system at my workplace. Currently I am working from home on my indivisual system so I could send you the another result. Really appritate your code , it is robust, I will work on it to get the results. Thank you .
Star Strider
Star Strider 2020-4-14
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

请先登录,再进行评论。

标签

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by