MATLAB:如何计算两个信号的相似度并获得正确的一致性或相干性度量

MATLAB: How to compute the similarity of two signals and get the correct consistency or coherence metric

我想知道一致性指标。通常,它可以让我们推断出两个信号之间的奇偶校验或相似性,对吗?如果是这样,如果概率更高(从 0.5 到 1),是否意味着信号有很强的相似性?如果余量小于(0.1-0.43),这是否可以预测信号之间的一致性差(或相似性差,信号不同的概率)?所以,如果我们得到的指标 <0,这是否表明信号完全不同?因为我得到负数。这个假设可能吗?

我可以清楚地了解信号的一致性指标吗?这是我的小代码和数字。提前致谢。

s1 = signal3
s2 = signal4     

if  s1 ~= s2
    [C1] = xcorr(s1);        
    [C2] = xcorr(s2);
    signal_mix = C1.*C2   %mixing vector
    signal_mix1 = signal_mix
else
    s1(1,:) == s2(1,:)
    s3 = s1
    s3= s2
    signal_mix = s2
end

n =2;
   
for i = length(signal_mix1)
    signal_mix1(i) = min(C1(i),C2(i))/ max(C1(i),C2(i)) % consistency score
    signal_mix2 = sum(signal_mix1(i))
end

首先,您可以使用xcorr函数来计算两个信号之间的互相关。 来自 Matlab help:

r = xcorr(x,y) returns the cross-correlation of two discrete-time sequences. Cross-correlation measures the similarity between a vector x and shifted (lagged) copies of a vector y as a function of the lag. If x and y have different lengths, the function appends zeros to the end of the shorter vector so it has the same length as the other.

另外你可以使用 xcov:

xcov computes the mean of its inputs, subtracts the mean, and then calls xcorr.

The result of xcov can be interpreted as an estimate of the covariance between two random sequences or as the deterministic covariance between two deterministic signals.

在您的示例中,您将 xcorr 与一个信号一起使用,因此它会计算信号本身与其滞后信号之间的自相关。

更新: 根据评论,似乎你需要线性相关,它可以通过 corr 函数计算:

p=corr(x,y)

当 x 和 y 的行为完全相同时,p 的值为 1,当 x 和 y 的行为完全相反时,p 的值为 -1。 当 p 为 0 时,表示两个信号之间没有相关性。

根据您的用例,您可能需要考虑 d动态 time w强奸距离(Matlab has a build in function for that)作为相似性度量。使用相关性作为度量的一个问题是它总是比较信号的相同时间步长。因此,两个相同的信号,其中一个是时间延迟的,可能会导致低相关性。 DTW 距离通过与相邻时间步的值进行比较来解决这个问题。

dtw 距离的缺点是它自身的距离不能仅相对于其他距离进行解释。所以你可以看出距离为 150 的两个信号 A 和 B 比距离为 250 的 A 和 C 更相似。但是 150 本身的距离并不能告诉你很多。