MATLAB Answers

How to detect the index of rising and falling edges of every pulse in a signal composed of many pulses ?

15 views (last 30 days)
pankaj singh
pankaj singh on 28 Apr 2017
Hello, I have a signal which has many pulses. I need to detect the index of the starting and falling edges of each of the pulses in the signal. How can do it? I am using the following code (but it gives me empty startIndex and endIndex matrix when the signal value is too low) and sometimes more no. of indexes than the pulses. [ Note that I can't optimize the given values for each signal in a monte carlo run.]
y = given signal;
minL = 150; %minimum samples for signal burst.
Ty = zeros(size(y));
Ty(abs(y)>9e-7)= y(abs(y)>9e-7);
edgefilt = [ones(1,minL) -ones(1,minL)];
Edges = [zeros(1,minL-1) conv(abs(Ty),edgefilt/50,'valid') zeros(1,minL)];
tsig = (abs(Edges)~=0); % converting the desired signal into 0's and 1's
dsig = diff([0 tsig 0]);
startIndex = find(dsig > 0);
endIndex = find(dsig < 0)-1;
duration = endIndex-startIndex+1;

Answers (0)

Community Treasure Hunt

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

Start Hunting!