2015-10-22 25 views
1

我想測量圖中所示的的波峯/波峯之間的週期。如何測量波峯或低波之間的週期?

enter image description here

這是鈣濃度在細胞中的振盪行爲。峯值不一樣,因此我需要計算每個波峯的峯值/低值,獲得與峯值/低值相關的相應時間,找到相鄰峯值/低值之間的差值。我已經存儲了每次「0.01」的鈣濃度值。

任何人都可以建議我如何編碼嗎?我寧願使用更小的代碼行。

回答

1

研究內置的findpeaks函數,該函數可以返回信號中峯值的索引。

您可以通過首先對信號進行平方來找到信號中的低點。像這樣的東西可以工作(我沒有在MATLAB中嘗試過,所以可能會有一些語法問題):

% Square the signal so that the lows become peaks 
signal = signal .^ 2; 

% Get the location of the peaks in terms of t (your time vector) 
[~, peaksAndLows] = findpeaks(signal,t) 

% Find the difference between consecutive peaks/lows 
periodsBetweenPeaksAndLows = diff(peaksAndLows); 
+0

'findpeaks'和'diff'就像一個魅力一樣工作。非常感謝@Sam – nashynash

+0

不用擔心,很高興幫助! – Sam