簡體   English   中英

Matlab-查找有趣信號的開始和停止

[英]matlab - find start and stop of an interesting signal

我有一個看起來像這樣的信號: 在此處輸入圖片說明

我想找到一種方法來定位中間部分的開始和結束。

我所做的是將高於和低於0.5的值設為常數==> 1,並且如果我在行中多次發現1,則表示這是我的信號...但是我猜這不是一個好方法! 首先,我的“閾值”並非每次都為0.5,並且我確信存在某種更好的方法。

如果你們有一些文檔或想法。

非常感謝你。

正如其他人所提到的,更多的是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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM