MATLAB: Find the start and end position of a data frame in a pulsed signal

r2014asignal processing

Hello everyone,
I have a signal like this:
and would like a good way to find the start and end of each frame. Note that the size of each frame can be variable and sometimes the flat part in between could have an offset.
Thanks for your time and effort,
Paul

Best Answer

so what one would do first is threshold a signal and perform an edge detection on it. something like this:
close all;
figure(1)
x = 0:.001:10;
y = 10*sin(50*pi*x);
bduration = [996 830 449 898 680 200];
bpoints = [1 3275 4582 5758 8211 9800];
for ind = 1:length(bduration)
y(bpoints(ind):bpoints(ind)+bduration(ind)) = 0;
end
y = y+(2*rand(1,length(x))-1);
minL = 160; %minimum samples for signal burst.
Ty = zeros(size(y));
Ty(abs(y)>5) = y(abs(y)>5);
edgefilt = [ones(1,minL) -ones(1,minL )];
Edges = [zeros(1,minL-1) conv(abs(Ty),edgefilt/160,'valid') zeros(1,minL)];
plot(x,y,x,Edges,'r');
and as you can see from the final plot just find the locations of the peaks.