我是靠谱客的博主 内向雪糕,这篇文章主要介绍matlab 计算过零率,现在分享给大家,希望可以做个参考。

function count = zero_crossings(x)
% x 必须是1位的行向量或者列向量 时域信号
% count为返回的过零率计算

% 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)
        count = count + 1;
    end
    
end

 

最后

以上就是内向雪糕最近收集整理的关于matlab 计算过零率的全部内容,更多相关matlab内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(65)

评论列表共有 0 条评论

立即
投稿
返回
顶部