Finding upper and lower (min and max) states

2 visualizzazioni (ultimi 30 giorni)
SHANTANU KSHIRSAGAR
SHANTANU KSHIRSAGAR il 12 Apr 2020
Commentato: Star Strider il 14 Apr 2020
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 Commenti
darova
darova il 12 Apr 2020
Can you show something?
SHANTANU KSHIRSAGAR
SHANTANU KSHIRSAGAR il 12 Apr 2020
yes i have figure of some data related to signal

Accedi per commentare.

Risposte (1)

Star Strider
Star Strider il 13 Apr 2020
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 Commenti
SHANTANU KSHIRSAGAR
SHANTANU KSHIRSAGAR il 14 Apr 2020
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 il 14 Apr 2020
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Accedi per commentare.

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by