MATLAB計算信號的過零率

1. 基本原理

因爲低壓波動或背景噪聲的存在,會增長信號的振幅值超過零振幅電平的次數。ide

爲避免低壓波動或背景噪聲帶來的影響,信號振幅實施閾值條件,獲得下述公式。函數

過零率的計算公式以下:
在這裏插入圖片描述
spa

2.MATLAB代碼

function count = zero_crossings(x,thr)
% x是時域信號,必須是1位的行向量或者列向量;
% thr是設定的閾值
% count是該函數計算信號x過零率的值
 
% initial value
count = 0;
 
% error checks
if(length(x) == 1)
    error('ERROR: input signal must have more than one element');
end
 
if((size(x, 2) ~= 1) && (size(x, 1) ~= 1))
    error('ERROR: Input must be one-dimensional');
end
    
% force signal to be a vector oriented in the same direction
x = x(:);
 
num_samples = length(x);
for i=2:num_samples
    % Any time you multiply to adjacent values that have a sign difference
    % the result will always be negative.  When the signs are identical,
    % the product will always be positive.
    if(((x(i)*x(i-1)) < 0)&&(abs(x(i)-x(i-1))>thr))
        count = count + 1;
    end 
end

參考文獻

[1]Feature reduction and selection for EMG signal classification.
[2]matlab 計算過零率
.net

若是以爲這篇博客是你須要的,請動動你的手指,點個贊吧,謝謝你的鼓勵;若是你對我寫的博客感興趣,歡迎你常來個人主頁看看,期待你的關注。3d

相關文章
相關標籤/搜索