我对参考信号和一系列其他信号之间的相关性感兴趣。为此,我使用了斯皮尔曼的系数。此外,我想解释一下为什么某些数据的相关性更强,而其他数据的相关性弱。显而易见的答案显而易见:“信号相似/不相似”。我的想法是,我希望所有这些都是相似的,这就是为什么我感兴趣的原因。
假设我有这3个信号:
ref = [0.153698000000000 0.159227000000000 0.153578000000000 0.135617000000000 0.106725000000000 0.0720750000000000 0.0383580000000000 0.00419000000000000 -0.0406150000000000 -0.104511000000000 -0.178757000000000 -0.237172000000000 -0.248983000000000 -0.201136000000000 -0.112051000000000 -0.0171030000000000 0.0556220000000000 0.100198000000000 0.127225000000000 0.146429000000000 0.156469000000000 0.148586000000000 0.120207000000000 0.0822790000000000 0.0465630000000000 0.0127520000000000 -0.0302530000000000 -0.0892330000000000 -0.151656000000000 -0.187429000000000 -0.171909000000000 -0.106635000000000 -0.0207050000000000 0.0504730000000000 0.0890630000000000 0.101382000000000 0.102716000000000 0.103612000000000 0.101693000000000 0.0877250000000000 0.0557510000000000 0.00836400000000000 -0.0466150000000000 -0.101411000000000 -0.149962000000000 -0.184511000000000 -0.192687000000000 -0.163118000000000 -0.0969680000000000 -0.0117410000000000 0.0659480000000000 0.116307000000000 0.136674000000000 0.136510000000000 0.127171000000000 0.112167000000000 0.0907370000000000 0.0624430000000000 0.0266490000000000 -0.0188730000000000 -0.0752460000000000 -0.139144000000000 -0.194234000000000 -0.216676000000000 -0.188924000000000 -0.114953000000000 -0.0216350000000000 0.0608270000000000 0.116310000000000 0.147004000000000 0.166052000000000 0.179028000000000 0.180012000000000 0.161279000000000 0.121606000000000 0.0727670000000000 0.0258380000000000 -0.0186780000000000 -0.0675800000000000 -0.127120000000000 -0.188126000000000 -0.225266000000000 -0.212062000000000 -0.145823000000000 -0.0534320000000000 0.0279870000000000 0.0772470000000000 0.0977090000000000 0.108232000000000 0.121362000000000 0.131944000000000 0.126989000000000 0.100732000000000 0.0629320000000000 0.0262270000000000 -0.00548300000000000 -0.0427550000000000 -0.0963450000000000 -0.158377000000000 -0.203218000000000 -0.203878000000000 -0.149980000000000 -0.0592800000000000 0.0337540000000000 0.0997230000000000 0.128674000000000 0.133482000000000 0.128745000000000 0.122315000000000 0.112027000000000 0.0905840000000000 0.0587200000000000 0.0247430000000000 -0.00688800000000000 -0.0431370000000000 -0.0940400000000000 -0.156244000000000 -0.207234000000000 -0.217930000000000 -0.171546000000000 -0.0821420000000000 0.0148240000000000 0.0863420000000000 0.119430000000000 0.125936000000000 0.125051000000000 0.127984000000000 0.128781000000000 0.115835000000000 0.0852330000000000 0.0443400000000000 0.00490900000000000 -0.0255570000000000 -0.0544690000000000 -0.0948830000000000 -0.148332000000000 -0.197016000000000 -0.212808000000000 -0.179499000000000 -0.103302000000000 -0.0123390000000000 0.0617030000000000 0.104228000000000 0.119877000000000 0.122972000000000 0.125183000000000 0.125265000000000 0.114951000000000 0.0870480000000000 0.0447450000000000 -0.000855000000000000 -0.0396970000000000 -0.0696810000000000]
x= [0.271434000000000 0.288274000000000 0.209192000000000 0.0655440000000000 -0.0820200000000000 -0.148026000000000 -0.108114000000000 0.00370200000000000 0.0903880000000000 0.0670870000000000 -0.0543520000000000 -0.198260000000000 -0.266923000000000 -0.210663000000000 -0.0721470000000000 0.0476940000000000 0.0976820000000000 0.0815330000000000 0.0550950000000000 0.0509430000000000 0.0654310000000000 0.0761700000000000 0.0716700000000000 0.0496400000000000 0.0296730000000000 0.00932700000000000 -0.0220210000000000 -0.0918530000000000 -0.191917000000000 -0.273027000000000 -0.278303000000000 -0.193660000000000 -0.0558200000000000 0.0496270000000000 0.0822850000000000 0.0492800000000000 0.00158300000000000 -0.0250730000000000 -0.000159000000000000 0.0643930000000000 0.133856000000000 0.165200000000000 0.124040000000000 0.0217580000000000 -0.0914600000000000 -0.162790000000000 -0.156950000000000 -0.0734400000000000 0.0277270000000000 0.0829160000000000 0.0694490000000000 0.0286590000000000 0.0242190000000000 0.0770240000000000 0.144502000000000 0.164170000000000 0.111881000000000 0.0246120000000000 -0.0525930000000000 -0.0932270000000000 -0.117220000000000 -0.162008000000000 -0.231990000000000 -0.283092000000000 -0.257563000000000 -0.140892000000000 -0.0109250000000000 0.0575570000000000 0.0398860000000000 -0.0119950000000000 -0.0311610000000000 0.00895200000000000 0.0767310000000000 0.111818000000000 0.0770950000000000 -0.00480400000000000 -0.0648260000000000 -0.0590600000000000 -0.0239010000000000 -0.0113260000000000 -0.0503820000000000 -0.119773000000000 -0.166668000000000 -0.153385000000000 -0.0951590000000000 -0.0134120000000000 0.0758570000000000 0.169250000000000 0.265192000000000 0.320269000000000 0.312399000000000 0.248779000000000 0.170381000000000 0.116544000000000 0.0825490000000000 0.0229900000000000 -0.112957000000000 -0.311565000000000 -0.477718000000000 -0.528972000000000 -0.441705000000000 -0.277521000000000 -0.132652000000000 -0.0641130000000000 -0.0469650000000000 0.00307500000000000 0.145157000000000 0.348731000000000 0.493012000000000 0.479475000000000 0.325143000000000 0.114432000000000 -0.0427650000000000 -0.100921000000000 -0.0959820000000000 -0.103768000000000 -0.157386000000000 -0.232400000000000 -0.260288000000000 -0.205974000000000 -0.107415000000000 0.00374900000000000 0.0959960000000000 0.175779000000000 0.259562000000000 0.343460000000000 0.392091000000000 0.364989000000000 0.262129000000000 0.115872000000000 -0.0238940000000000 -0.112717000000000 -0.167219000000000 -0.228616000000000 -0.308254000000000 -0.357301000000000 -0.323026000000000 -0.200829000000000 -0.0399150000000000 0.0773370000000000 0.106666000000000 0.0934510000000000 0.134411000000000 0.283691000000000 0.484582000000000 0.615659000000000 0.578599000000000 0.376662000000000 0.121242000000000 -0.0499920000000000 -0.0908270000000000 -0.0512570000000000 -0.0251360000000000]
y=[0.0805620000000000 0.0193840000000000 0.0317950000000000 0.0923790000000000 0.157971000000000 0.196456000000000 0.213476000000000 0.217857000000000 0.199800000000000 0.132178000000000 0.00511700000000000 -0.129106000000000 -0.200164000000000 -0.161512000000000 -0.0533460000000000 0.0447720000000000 0.0777510000000000 0.0457860000000000 -0.000266000000000000 -0.00166500000000000 0.0469650000000000 0.100767000000000 0.105057000000000 0.0487410000000000 -0.0139600000000000 -0.0339380000000000 -0.0268990000000000 -0.0467280000000000 -0.117983000000000 -0.191721000000000 -0.206983000000000 -0.126591000000000 0.0368150000000000 0.187842000000000 0.245185000000000 0.207442000000000 0.113449000000000 0.0277730000000000 -0.0201070000000000 -0.0340330000000000 -0.0418780000000000 -0.0577930000000000 -0.0687330000000000 -0.0774580000000000 -0.112039000000000 -0.203065000000000 -0.325518000000000 -0.408340000000000 -0.384561000000000 -0.233895000000000 -0.000200000000000000 0.206361000000000 0.301673000000000 0.258327000000000 0.158405000000000 0.0850420000000000 0.0638960000000000 0.0601920000000000 0.0267320000000000 -0.0495640000000000 -0.140141000000000 -0.216581000000000 -0.246500000000000 -0.220618000000000 -0.159008000000000 -0.0645680000000000 0.0638910000000000 0.195499000000000 0.292969000000000 0.314935000000000 0.253050000000000 0.141489000000000 0.0485870000000000 0.0141340000000000 0.00904500000000000 -0.0209880000000000 -0.102024000000000 -0.191704000000000 -0.229835000000000 -0.193077000000000 -0.117835000000000 -0.0788180000000000 -0.132543000000000 -0.227262000000000 -0.261066000000000 -0.146183000000000 0.0732720000000000 0.288526000000000 0.393861000000000 0.375488000000000 0.312956000000000 0.280953000000000 0.293536000000000 0.294787000000000 0.228394000000000 0.0812080000000000 -0.0979610000000000 -0.219818000000000 -0.247000000000000 -0.203883000000000 -0.152293000000000 -0.128943000000000 -0.114403000000000 -0.0782120000000000 -0.0208240000000000 0.0301690000000000 0.0414160000000000 0.00930500000000000 -0.0224010000000000 -0.0127020000000000 0.0374780000000000 0.0839880000000000 0.0805340000000000 0.0179880000000000 -0.0578820000000000 -0.103678000000000 -0.0949510000000000 -0.0417700000000000 0.0216980000000000 0.0582560000000000 0.0632220000000000 0.0520980000000000 0.0350020000000000 0.0327130000000000 0.0430200000000000 0.0648000000000000 0.0662060000000000 0.0380750000000000 0.00131200000000000 -0.0341550000000000 -0.0591350000000000 -0.0705680000000000 -0.0688930000000000 -0.0640920000000000 -0.0680670000000000 -0.0878340000000000 -0.112712000000000 -0.137633000000000 -0.136924000000000 -0.0989540000000000 -0.0408820000000000 0.0148740000000000 0.0569500000000000 0.0903410000000000 0.119637000000000 0.161266000000000 0.213775000000000 0.254719000000000 0.255163000000000 0.198274000000000 0.106108000000000 0.0180750000000000 -0.0376770000000000]
corrcoef(ref,x) = 0.7448
(我不知道为什么我会因correcoef
而得到4个值)。
corrcoef(ref,y) = 0.6860
。
现在,我不能仅仅通过查看原因或稍微弱一点的相关性来判断,所以我试着看看频率:
现在,我的猜测是因为每个信号的信噪比。我想计算每个信号的SNR,但这里是我卡住的地方。我发现的与SNR相关的所有公式都提前知道哪一个是信号,哪一个是噪声,但我不知道。我想要计算SNR的方法是将能量放在最高峰值并将其除以其余峰值中的能量,但我不知道如何在matlab中做到这一点。我想最高峰我可以指向光标,但我如何计算其余峰值的总能量呢?
PS:我已经尝试过Matlab的a = snr(x) ;
而且我得到了
Undefined function 'snr' for input arguments of type 'double'.
即使列出工具箱>> ver,信号处理工具箱版本6.19,它也是列表中的一个。 谢谢!
稍后编辑:如果我尝试这个怎么办:
Energy = abs(fft(ref, NbOfPoints)) //get the magnitudes for FFT in NbOfPoint
Energy = Energy(1:NbOfPoints/2) // keep the first half, the others are mirrored
[HP index] = max(Energy) // get the magnitude of the highest peak and it's position
Energy(index)=0 // set the Highest Peak to 0
SNR = HP / sum(Energy) // compute magnitude of highest peak / sum of others
这是相关的吗?结果很明显(0.02~0.03),我不知道这是否是一种比较信号和噪声的可接受方式。也许我应该在最高峰附近选择一些豆类而不是最高峰?喜欢(HP-2:HP + 2)?
答案 0 :(得分:0)
当试图解释为什么它们在时域中或多或少相关时,你必须小心地阅读信号的谱域。虽然我理解您尝试量化每个信号的SNR的方法,但您还要说明您不知道什么是信号,什么是噪声。参考信号的图表显示主光谱峰值存在谐波,这些也是信号的一部分(而不是噪声)。
如果绘制两个信号相对于ref信号的x-y图,则执行相关操作。
plot (ref,x,'.')
hold on
plot (ref,y,'.r')
因此,逐点(或逐个样本),与x或y线性增加相关的ref信号增加。信号以线性方式一起变得越大,它们就越相关。
有时查看互相关以查看信号是否存在滞后是有用的。如果是这样,您可能会发现峰值相关性不是在滞后0处发生(这相当于运行简单相关),而是在信号之间存在一定量的滞后。
[LAGS,C] = xcorr ([ref',x'])
plot(LAGS,C)
您可能还希望运行一致性分析,以查看两个信号之间的频率内容相似。这将有助于您确定不在频谱峰值处的信号是否全部是噪声,或者是否存在实际“信号”的其他频谱内容(包括谐波)。