How can I (for a digital signal) estimate the interval between steps of amplitude 1?
Show older comments
I have a footswitch signal that when is active it gives 1 and when is deactivated delivers 0 sampled every 1 ms; I want to estimate how long is the interval between each step (from the instant when the switch is activated). Considering that only the steps with a duration longer than 5 ms are acceptables. The size of the interval is recorded at the corresponding column of a "vector". For that purpose I´ve developed the code:
for ii=1 : length(vector)
for jj=step : length(footswitch) %Go around the vector of the signal footswitch
while footswitch(jj)==1
if jj < length(footswitch)-4
if footswitch(jj)==footswitch(jj+1)==footswitch(jj+2)==footswitch(jj+3)==footswitch(jj+4)==1
k=jj;
if footswitch(k)==1
steps=k+1;
end
end
end
end
end
for aa=steps : length(footswitch)
while footswitch(jj)==0
p=aa;
if footswitch(p)==0
stepss=p+1;
end
end
end
intervalo=stepss;
vector(ii)=intervalo;
end
Can anyone tell me what is wrong with the code? I've tested it and it gives me a wrong estimation for the first interval and then it just go worse!
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!