零交叉数-方程式 [英] Number of Zero-crossings - Equation

查看:164
本文介绍了零交叉数-方程式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一种算法,可以计算信号中的过零次数.我的意思是,值从+变为-的次数,反之亦然.

I have written an algorithm that calculates the number of zero-crossings within a signal. By this, I mean the number of times a value changes from + to - and vice-versa.

该算法的解释如下:

如果包含以下元素:

v1 = {90, -4, -3, 1, 3}

然后将值乘以它旁边的值. (i * i + 1)

Then you multiply the value by the value next to it. (i * i+1)

然后使用符号值sign(val)确定这是正数还是负数.示例:

Then taking the sign value sign(val) determine if this is positive or negative. Example:

e1 = {90 * -4} = -360 -> sigum(e1) = -1 
e2 = {-4 * -3} =  12  -> signum(e2) = 1
e3 = {-3 *  1} =  -3  -> signum(e3) = -1
e4 = {1 *   3} =  3   -> signum(e4) = 1

因此,从负到正的值总数为= 2 ..

Therefore the total number of values changed from negative to positive is = 2 ..

现在,我想将此论坛式算法放到一个方程式中,以便我可以展示它.

Now I want to put this forumular, algorithm into an equation so that I can present it.

我问了一个类似的问题,但是真的很困惑,于是走开了,然后思考了一下,然后提出了(我认为等式应该看起来像什么).这可能是错误的,嗯,可笑的是错误的.但是这里是:

I have asked a simular question, but got really confused so went away and thought about it and came up with (what I think the equation should look like).. It's probably wrong, well, laughably wrong. But here it is:

现在,其背后的逻辑是:

Now the logic behind it:

我输入了V(值)

我通过计算(Vi * Vi + 1)得出信号总和的绝对值.信号(Vi * Vi + 1)应该产生-1,1,...,值

I get the absolute value of the summation of the signum from calculating (Vi * Vi+1) .. The signum(Vi * Vi+1) should produce -1, 1, ..., values

当且仅当值是-1时(因为我只对零越过的次数感兴趣,因此,零值就可以了.

If and only if the value is -1 (Because I'm only interested in the number of times zero is crossed, therefore, the zero values.

这看起来是否正确,如果不正确,有人可以提出改进建议吗?

Does this look correct, if not, can anyone suggest improvements?

谢谢:)!

现在正确吗?

推荐答案

您在这里做的正确,但是您的方程式是错误的,因为您只想计算相邻元素乘积为负时的正负号.不要对产品的标志求和,因为应该忽略正号产品.由于这个原因,一个明确的数学公式是棘手的,因为应该忽略相邻元素之间的正积.您想要的是一个函数,该函数需要2个参数,并且当它们的乘积为负时,其值为1;当非负时,其值为0

You are doing the right thing here but your equation is wrong simply because you only want to count the sign of the product of adjacent elements when it is negative. Dont sum the sign of products since positive sign products should be neglected. For this reason, an explicit mathematical formula is tricky as positive products between adjacent elements should be ignored. What you want is a function that takes 2 arguments and evaluates to 1 when their product is negative and zero when non-negative

f(x,y) = 1 if xy < 0
       = 0 otherwise

那么您的交叉点数就简单地由

then your number of crossing points is simply given by

sum(f(v1[i],v1[i+1])) for i = 0 to i = n-1 

其中,n是向量/数组v1的长度(使用基于零索引的C样式数组访问符号).您还必须考虑边缘条件,例如4个连续点{-1,0,0,1}-您是否要将其简单地视为一个零交叉或2?只有您可以根据问题的具体情况回答此问题,但是无论您的回答如何,都将相应地调整您的算法.

where n is the length of your vector/array v1 (using C style array access notation based on zero indexing). You also have to consider edge conditions such as 4 consecutive points {-1,0,0,1} - do you want to consider this as simply one zero crossing or 2??? Only you can answer this based on the specifics of your problem, but whatever your answer adjust your algorithm accordingly.

这篇关于零交叉数-方程式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆