[英]matlab - find start and stop of an interesting signal
正如其他人所提到的,更多的是DSP問題,dsp.stackexchange.com將為您提供更好的答案,但是在此之前可能會有所幫助:
data=csvread('acceleration.txt',1)
threshold_y=max(data)*0.5; %Thanks to GameOfThrows
thershold_x=101; %how many zeros can be between to ones to still count as continuous
addframe=50; %if you want a little bit of data before and after the active area
logic_index=data>threshold_y;
num_index=find(logic_index);
distance=diff(num_index);
gaps=[1 ; find(distance>thershold_x)]; %find the gaps bigger than your threshold
final_index=false(length(data),1);
for i=1:length(gaps)-1 %add ones between
final_index(num_index(gaps(i)+1)-addframe:num_index(gaps(i+1))+addframe)=true;
end
plot(x,data,x,final_index);
它基本上就是您在問題中描述的內容,但是增加了在區域之間處理零的問題。 感謝@GameofThrows提供了門檻主意。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.