我有两个嘈杂的信号:
vv =
130.004701157424 0.0324551387935370 -0.00451469350442727
130.011647685172 0.0293209698881577 -0.00443672007848742
130.018593981487 0.0174427299727758 -0.00604150583046056
130.025540509235 0.00932950167238858 -0.00674349719282885
130.032484953732 0.00662683499867775 -0.00652548843970368
130.039431597197 0.00963962170597527 -0.00271561211198806
130.046378009228 0.00916636267883020 -0.00458483912768415
130.053323495409 0.00848153573266126 -0.00542464163811399
130.060270138874 0.0104189382416956 -0.00464131395425218
130.067215277788 0.00953497010962494 -0.00598548927183946
130.074161689819 0.0125977970865675 -0.00236431037166667
130.081106944449 0.0157313089275160 -0.00124953996090587
130.088053587915 0.0103333882964656 -0.00417575754540960
130.095000231496 0.0108738998659066 -0.00134972601854648
130.101946874961 0.0137694481434158 0.000439871274351066
130.108893402826 0.0106008069840205 0.00186444703878395
130.115839930575 0.00601970125521576 0.000359414960086779
130.122786342606 0.0108009060625473 0.000440760947416785
130.129732986071 0.00503317203604985 -0.00189482334703281
130.136679629653 0.00348671530646311 -0.00597670527650866
130.143626273118 0.00300096809365072 -0.00400691470698012
130.150572569433 0.0142183275779423 -0.00804978952801293
130.157519328731 0.0230525240949860 -0.00521843258757276
130.164466319463 0.0280086287368616 -0.00668926653224850
130.171412962929 0.0214224391615698 -0.00787607758546161
130.178359490793 0.0168846248864780 -0.0145337319344219
130.185306134259 0.0239192800093970 -0.0181421164380445
130.192253009274 0.0210498390508919 -0.0184306704321636
130.199198611055 0.0179971812563166 -0.0218520121706652
130.206145486070 0.0103460380242347 -0.0159440755718102
130.213092361085 0.00807329993777163 -0.0159555444729480
130.220039467651 0.00912526344030146 -0.0127874433100412
130.226986342550 0.00987789917673930 -0.0133068804083725
130.233932291714 0.0146335693682593 -0.0146516075525065
130.240879166613 0.0197736097409092 -0.0166339708382938
130.247826041628 0.0237299835348641 -0.0125980372608054
130.254772337943 0.0159187859188923 -0.0143153263534319
130.261718518540 0.0108969610019023 -0.0176225456453581
130.268663425904 0.0113948628098992 -0.0154783872650768
130.275610416636 0.00550151729857086 -0.0162109325490846
130.282555902817 0.0109876298475660 -0.0153331746399511
130.289503124982 0.00549384751028331 -0.0166060194162694
130.296449999998 0.00578884116574096 -0.0159344196006499
130.303394675927 0.00790183949292702 -0.0153635837219086
130.310341550943 0.00618938542567369 -0.0150381094970244
130.317288078691 0.00265099365518004 -0.0171663309551115
130.324235300973 0.00273994060860974 -0.0145340255449315
130.331182060155 -0.00151750931024957 -0.0143517639050771
130.338128935171 -0.00358804234355178 -0.0198922665378706
130.345076620320 -0.00382232746918610 -0.0176678440329436
130.352024305586 -0.000693949984437276 -0.0169212697877281
130.358971064768 0.00650620967722442 -0.0170218577527335
130.365918055500 0.0201962605199323 -0.0140533168589787
130.372864236098 0.00731475005500598 -0.0150833328404646
130.379811921248 0.0147341961991546 -0.0129639299478812
130.386759143530 0.00921475919358350 -0.0161000768186993
130.393706365695 0.00593047075608162 -0.0133553645712844
130.400653240711 0.00516910535303972 -0.0173593220662748
130.407599305592 0.00458812986283153 -0.0159890785453408
130.414546759308 0.0123842255133543 -0.0185143837967815
130.421493750040 0.00831229147094524 -0.0153532081457558
130.428440740772 0.00875956790369065 -0.0163487971058285
130.435387499954 0.00900962706783174 -0.0185691489107274
130.442333796269 0.0123889408681948 -0.0182074899466804
130.449281365701 0.0152967329894126 -0.0184572729268484
130.456228472267 0.0165450555725402 -0.0164807811464941
130.463175000015 0.0260987363550796 -0.0140089856402594
130.470122338014 0.0321476361526084 -0.0141177661243760
130.477070254597 0.0316615905504380 -0.0116512722757364
130.484017245329 0.0198831104884075 -0.0119145477910928
130.490964930595 0.0266420661754116 -0.0100765551384381
130.497912037044 0.0247996470494997 -0.00841304990074580
130.504859259210 0.0263440804991336 -0.00568623791784806
130.511805439808 0.0311188115790501 -0.00903519920180561
130.518751736122 0.0273145321089672 -0.00538382519970312
130.525697800887 0.0235173617390519 -0.00261262367193117
130.532644328752 0.0312466106165505 -0.00251050736973128
130.539590277800 0.0297431011841171 -0.00751586454533614
130.546537962949 0.0286264834035095 -0.00575901110708388
130.553483449130 0.0270058241397517 -0.00251086749982294
130.560426620391 0.0269740082953162 0.00194420717998295
130.567370370354 0.0269780887795340 -0.00105897340483095
130.574313194465 0.0247531916317612 -0.000658590614742004
130.581258564812 0.0235006810769230 0.00175385001759932
130.588203356459 0.0184218003234307 0.00594495497455634
130.595147337971 0.0145457172743063 0.00130263829493817
130.602092592602 0.0140290282748285 0.00636268308868845
130.609038888917 0.0112095778161458 0.00405890169473626
130.615984606531 0.0123477430392898 0.00667915590023187
130.622929976878 0.0173522535329642 0.00610129390593689
130.629873495407 0.0243085279171429 0.00778791439018682
130.636818634204 0.0204177173633550 0.00727095690422537
130.643763425967 0.0136653938804994 0.00804683674033229
130.650709375015 0.0124415695556724 0.00786145469637907
130.657653240694 0.0138946573618692 0.00858570669557563
130.664598611158 0.0166125649093933 0.00692805363164324
130.671541550869 0.0170153994249751 0.00376972837524243
130.678487615750 0.0259979013326192 0.00613225792836833
130.685432291680 0.0292872930450090 0.00680183673070099
130.692378125011 0.0241836040209334 0.00341128173237620
130.699322569391 0.0211658785218161 0.00525108568057152
130.706269097256 0.0174065996629161 0.0102735112806192
130.713215162020 0.0244029939810822 0.00617649608165125
130.720160648201 0.0308685919870497 0.0102049760766938
130.727105902831 0.0318680007000358 0.0151940055609854
130.734052430580 0.0335329704999579 0.0130576282886414
130.740998263911 0.0317550665189883 0.0123711218012938
130.747943981525 0.0338530590274587 0.00800534362963763
130.754889351872 0.0355948634475302 0.00803021790432679
130.761835532353 0.0379717809064523 0.0118224061440078
130.768780324117 0.0344709868173581 0.0144617653568690
130.775726041614 0.0347918293905032 0.0110525719816612
130.782670601827 0.0367645195321477 0.0120799232062315
130.789616203725 0.0334616641122058 0.0122765083970491
130.796561458355 0.0342625020064189 0.00921761682666889
130.803506365719 0.0285523281234837 0.0134444207226606
130.810451157365 0.0331506945581515 0.0191899527295108
130.817396296279 0.0397013227991109 0.0170379501667732
130.824339004673 0.0407669203934199 0.0200727547353931
130.831283333336 0.0478871637734401 0.0244247582307331
130.838228240700 0.0408618839785955 0.0243414762641529
130.845170949094 0.0415804166925540 0.0250367157898041
130.852113078672 0.0516414302749366 0.0278602293650065
130.859058333302 0.0534956297050274 0.0256323115805525
130.866004861167 0.0587947836338708 0.0268043272107924
130.872949305547 0.0555185884955733 0.0243414626671708
130.879896874979 0.0575501025180937 0.0232977173937327
130.886843518561 0.0628553903575701 0.0245039237817853
130.893791319427 0.0662032501163601 0.0192134916738424
130.900737847176 0.0635672161301594 0.0244152928076735
130.907684375040 0.0631971340972655 0.0218225356874009
130.914629282404 0.0601956351175908 0.0220323768257514
130.921575810152 0.0615947603717025 0.0216393032715897
130.928521296333 0.0633700871608101 0.0211651378529622
130.935468865765 0.0604455389157448 0.0180482921102740
130.942414004679 0.0598902794889758 0.0225695023361722
130.949360648144 0.0609750166589351 0.0198710505657090
130.956305787058 0.0601066368353604 0.0221214388738460
130.963251041688 0.0650144837082769 0.0188895816667075
130.970198726838 0.0612597200752886 0.0157961054554685
130.977145138869 0.0640914309476881 0.0136365447754670
130.984092708302 0.0642525972057988 0.0149770898087904
130.991039004617 0.0641777756342788 0.0154976461227700
130.997986921316 0.0689766791171059 0.0105116066241767
131.004932407380 0.0670590977086140 0.0106867556420315
131.011877546294 0.0616023731596080 0.00995940011167283
131.018823842609 0.0642233148019742 0.00610075043484476
131.025770138923 0.0618348820108556 0.00499665297278329
131.032717245372 0.0628526022483347 0.00617459925891050
131.039663425970 0.0595922198501596 0.0103103830130933
131.046609143468 0.0553992117880178 0.00660506573306566
131.053555324066 0.0591929936021142 0.00625505819393851
131.060501273114 0.0597653633182459 0.00986437021675432
131.067447337995 0.0577586417733864 0.00569030714546696
131.074393518476 0.0572022829298018 0.00552767005897976
131.081339699074 0.0521482842922390 0.00300737088905171
131.088285879672 0.0493907530001598 0.00402396921038598
131.095232060153 0.0543100574278050 0.00211340817585024
131.102177430501 0.0532726315849213 -0.000996186333010725
131.109123611098 0.0435924023275021 -0.000732867398863349
131.116068171311 0.0393832279694316 -0.00194512568853067
131.123014120359 0.0401122489975245 -0.000548658148349468
131.129960532391 0.0385925348998968 -4.06833992466838e-05
131.136905671304 0.0367309617348125 -0.00207215411154727
131.143851620352 0.0349056157508192 -0.00205058210954806
131.150799074068 0.0328696183679943 -0.00133161915021032
131.157742013896 0.0347941977690749 -0.00524369632099903
131.164687037093 0.0384693528516317 -0.00447981034266742
131.171632638874 0.0388991133955227 -0.00610384757612499
131.178577893504 0.0392851833874640 -0.00493109497479251
131.185522800984 0.0367626741897185 -0.00410241565669029
131.192468865749 0.0383606171007927 -0.00593377345607378
131.199413078695 0.0362952056937326 -0.00784902599550285
131.206357870342 0.0332167791201225 -0.00372184256451437
131.213304398206 0.0331134762296300 -0.00501735693009854
131.220250925955 0.0412988060560842 -0.00759454495853217
131.227197453703 0.0397244899760068 -0.00818996641892559
131.234143750018 0.0446725914614798 -0.00612847296947744
131.241090046332 0.0420463586455278 -0.00583859004196371
131.248036226814 0.0437993288470138 -0.00856079080564080
131.254982523129 0.0450911819989674 -0.00635831140902296
131.261928703726 0.0443881954439863 -0.00520235738468686
131.268874189791 0.0491447266115222 -0.00704099197742497
131.275820833372 0.0454428394558733 -0.00485611415531471
131.282765856453 0.0486849065468990 -0.00707865868309159
131.289712152767 0.0504940094988358 -0.00157654006424823
131.296658680516 0.0530386674799791 -0.00299290807107003
131.303604745397 0.0524715115891931 -0.00612116946824107
131.310551273145 0.0458682347702377 -0.00662768338605840
131.317497569460 0.0422240054249507 -0.00618994355653073
131.324444097208 0.0440449530840628 -0.00752876790101361
131.331390624956 0.0449314555713677 -0.00789688984671315
131.338337152821 0.0426203808125579 -0.00468593894550849
131.345283564853 0.0435575017230648 -0.00784818858984622
131.352230324035 0.0462593958946013 -0.0102682137161973
131.359176967616 0.0419842136605030 -0.00820027661676955
131.366123958349 0.0359594511173479 -0.00828472695248002
131.373070717647 0.0429619362473594 -0.0126610969699444
131.380017824096 0.0430590735887860 -0.00647807171819450
131.386964699111 0.0455767105043226 -0.00711765350493441
131.393911458293 0.0454022131609273 -0.00580341785603082
131.400858217592 0.0519837468779914 -0.00649023302327943
131.407803819489 0.0426887633990038 -0.00765415296896267
131.414750347237 0.0529420425058456 -0.00240406198943850
131.421697106536 0.0552825937677333 -0.00646959165440068
131.428644212985 0.0531969080546970 -0.0116452901767395
131.435591203717 0.0524321541185253 -0.00941207581419048
131.442537963015 0.0489587867794195 -0.00804619299670356
131.449484722197 0.0427053575910049 -0.00856783969084956
131.456431828646 0.0429849815306349 -0.0120665959836715
131.463378472228 0.0550113252037017 -0.0100722989698091
131.470324189842 0.0579340574183199 -0.0120806064304246
131.477270717590 0.0619338602951362 -0.0109737177241927
131.484217129622 0.0577345418840181 -0.00793030529414225
131.491164236071 0.0446941325653314 -0.00593256657854394
131.498111458353 0.0421887453324615 -0.00589779401034811
131.505058449085 0.0372948048064539 -0.00900849544825724
131.512005208384 0.0390507438427083 -0.00487194785307266
131.518951620415 0.0381645326113884 -0.00762705271160442
131.525898611147 0.0424783441620848 -0.00905173841441040
131.532845370329 0.0374813583196310 -0.0101765263988325
131.539792245344 0.0337188491616810 -0.00475201255835527
131.546739004643 0.0259299793832763 -0.00178519956054124
131.553685879658 0.0321498819202716 0.00238691770363199
131.560632870390 0.0300569314111337 0.00120781582813816
131.567579861122 0.0307351421660412 0.00300503480598206
131.574526967571 0.0292989773626216 0.00866006998614298
131.581474074020 0.0318885513737449 0.00791080395207525
131.588421064869 0.0258069503673378 0.00587880681072778
131.595368287035 0.0270707938909797 0.00470772377918112
131.602315393483 0.0325353331692663 0.00858558282908448
131.609262731483 0.0398784442635936 0.00943622753906860
131.616209374948 0.0384161518960841 0.00683768394739982
131.623155208279 0.0468400462968921 0.00208007792448528
131.630102083294 0.0586917777411348 0.00605114983907562
131.637049189859 0.0589534186872856 0.00547178474305857
131.643996527742 0.0603768516875771 0.00752685551571799
131.650942361073 0.0526976485337436 0.00734070651683581
131.657889351805 0.0520469031455501 0.00567018319498953
131.664836805521 0.0540518383496729 0.0123867364395239
131.671782754685 0.0562401102247814 0.0113474809775515
131.678729745417 0.0568184246162380 0.00725399693866520
131.685675578748 0.0616967276210481 0.00969433247042134
131.692622106496 0.0603025377084500 0.00906003694074906
131.699567824111 0.0600305457975510 0.0117322333977469
131.706514236142 0.0635171905367912 0.0116720570118878
131.713460185190 0.0640325233774840 0.0144966303282292
131.720407407356 0.0655702112941154 0.0141653570142126
131.727354398204 0.0664223501395319 0.0153506023772672
131.734301736087 0.0568297701213287 0.0112170862209991
131.741248379668 0.0587528093575650 0.0130772212166544
131.748195486117 0.0574672497096236 0.0138703639635315
131.755142476849 0.0607343424970708 0.0141523627277801
131.762089699132 0.0619089300233533 0.0116567212317497
131.769036805581 0.0617794897319985 0.0108939077743208
131.775981481510 0.0612434185962576 0.0112365970668752
131.782926273157 0.0547896090646844 0.00972175041832612
131.789872685189 0.0575534173959433 0.00809440304988744
131.796818518520 0.0641312328569411 0.00913708366471404
131.803765972235 0.0610186291333401 0.00877283777068790
131.810713425951 0.0663360444319159 0.00902461178030641
131.817660416683 0.0676411654974640 0.00932510752681921
131.824607291699 0.0619242157724937 0.00785619694365744
131.831554050881 0.0628359586714490 0.0104562939388846
131.838500578745 0.0664714844478518 0.00923287592114393
131.845447569478 0.0702064114647339 0.00948997468914856
131.852395023193 0.0696941076249289 0.00897967106407636
131.859340856524 0.0687255189747678 0.0108746015666911
131.866288310240 0.0695042997873630 0.00915533160361407
131.873235648123 0.0700710161567484 0.00982633437035050
131.880181365737 0.0811208383681068 0.00811718880538073
131.887128703736 0.0736566824440302 0.00804455472113599
131.894075810185 0.0762650532682489 0.00517845027886387
131.901021643516 0.0713812210339911 0.00822540517635032
131.907969328665 0.0652518387026985 0.00370735893536933
131.914915161996 0.0645016193955100 0.00271099761681276
131.921860995327 0.0656205496183650 0.00567917887363935
131.928804976840 0.0626818284978336 0.000282063156230429
131.935752430556 0.0635464647057962 0.000580274100755748
131.942699537005 0.0566494388730308 0.00431660946708819
131.949646643570 0.0583525411330150 0.00277525764449119
131.956592013917 0.0596529719736909 0.00493360735378987
131.963538888932 0.0610801327966719 0.00343154478076365
131.970485763831 0.0631608078188618 0.00207255618093954
131.977432754680 0.0599516632575944 0.00172334574260520
131.984380092562 0.0598524038736555 0.00429462031922425
131.991327199128 0.0567873735033396 0.00123769683953092
131.998274189860 0.0538338332361625 0.00198994909017887
132.005221064759 0.0550579551158673 -0.00249959734021306
132.012167361073 0.0513248026494203 -0.00122223260656512
132.019111921286 0.0491895154110539 -0.00180010672543284
132.026056828650 0.0476692357284076 -0.00476450974438637
132.032998495360 0.0524899258214720 -0.00475888809953603
132.039943287007 0.0500982073998819 -0.00555833539140166
132.046888078653 0.0522093648368018 -0.00660130469926532
132.053832175883 0.0499191108638875 -0.00771434016901260
132.060776736096 0.0535031956712866 -0.00733786776070131
132.067719444490 0.0555732983026725 -0.00822099892651191
132.074665277821 0.0560626959851276 -0.00611423395938753
132.081607175965 0.0522720025083649 -0.00949864547015161
132.088552199045 0.0460141727021084 -0.0111864004085499
132.095497800943 0.0456659392245141 -0.00871128395314326
132.102443055573 0.0433286927215380 -0.0107623349828017
132.109386921252 0.0419849745397525 -0.00801739990674093
132.116329629647 0.0387390188634245 -0.0107573515089166
132.123275347261 0.0330727751424722 -0.0150569553020259
132.130220717608 0.0318127443263756 -0.0127272723348182
132.137166203672 0.0364567670450558 -0.0128709276252399
132.144109375051 0.0342287121069688 -0.0119896103757337
132.151054629681 0.0297918019223798 -0.00897914169021081
132.157999884311 0.0296256037886811 -0.0126487854216226
132.164945717642 0.0360290821093720 -0.00801020601982271
132.171890740723 0.0403938174748625 -0.00705915996178831
132.178836342620 0.0353021767827033 -0.00735206089326397
132.185779629599 0.0331795996056022 -0.0100213235631181
132.192725115779 0.0331569058696126 -0.00769504149961907
132.199670254576 0.0414409707000433 -0.00979003314090525
132.206615740757 0.0419021773926508 -0.00670772042685770
132.213561458371 0.0375111015969745 -0.00575890297225611
132.220507060152 0.0337352238165512 -0.00751052061730450
132.227453356466 0.0285397639189766 -0.00771402657163913
132.234397222262 0.0325982663895901 -0.00732173094862477
132.241343518460 0.0277308387294906 -0.0119691716795284
132.248288425940 0.0218910146898687 -0.00696870032603571
132.255234837972 0.0211966534869462 -0.00817345784534812
132.262181018570 0.0247869588376762 -0.00984313802684687
132.269127430601 0.0270024807721633 -0.00778388333983148
132.276073263932 0.0256695309425160 -0.0123254734426166
132.283018287013 0.0263989215368988 -0.00785086317462576
132.289964930594 0.0259620568447301 -0.0113905764832590
132.296910185225 0.0209857975644172 -0.00700874702672643
132.303855208305 0.0215751228686248 -0.00432029366027902
132.310800231502 0.0223669196947528 -0.00815668089673350
132.317746759250 0.0228319289448673 -0.00912167858220261
132.324692245314 0.0216307542625950 -0.00713917029470587
132.331638657462 0.0135028453915764 -0.00277651187195760
132.338585416644 0.00813390381829617 -0.00339156231002729
132.345532175943 0.0135096298509657 -0.00555915723450343
132.352478819408 0.0148582193704977 -0.00532521352475677
132.359423148187 0.0185929605425803 -0.00498162030696373
132.366368634251 0.0191984097086291 -0.00267056555763903
132.373315277833 0.0179767799398566 -0.000709246696449680
132.380261805581 0.0182765396118518 -0.00175696059383416
132.387206828661 0.0195270150964356 -0.00760521397608591
132.394151851858 0.0190134494656363 -0.00423139300074821
132.401097800906 0.0179654813687979 -0.000831554941118412
132.408044560204 0.0119242568063669 -0.00256134253015786
132.414990972236 0.0164268827087314 -0.00292530923495597
132.421937268551 0.0180304514957133 -0.00839390541281580
132.428883912016 0.0184064573515405 -0.00664066030639073
其中第一列是十进制日的时间,第二列和第三列是两个信号。此数据的图表如下所示:
情节清楚地表明一个信号滞后于另一个。因此,我想计算信号之间的平均相移。为此,我尝试了以下方法:
Nfft = 512;
n = 50;
Fs = 6;
[Pxy,~] = cpsd(vv(:,2),vv(:,3),hamming(n),n/2,Nfft,Fs);
coP = real(Pxy);
quadP = imag(Pxy);
phase = atan2(coP,quadP);
Sphase = nanmean(phase);
Sphase = Sphase * 180 / pi;
给出了
Sphase = 18.40
我所演示的方法是否有意义,是否正确?
答案 0 :(得分:2)
如评论中所述,一个选项是使用低通滤波器预处理信号。这可以在傅里叶域中方便地完成。我使用了互相关函数的乘法与an image registration application中不同的截止值。
适应您的问题,它看起来像是(从this excellent answer复制的部分代码):
N = size(vv, 1);
nfft = 2^nextpow2(2*N-1);
F=fft(vv(:,2), nfft);
M=fft(vv(:,3), nfft);
R=F.*conj(M);
扫描截断滤波和逆FFT:
r = ones(nfft,1);
for k = 0.1:0.05:0.9
r = ifft(R(1:end-ceil(k*nfft)));
r = r.*r;
end
估算翻译:
rmax = max(abs(r));
x = find(abs(r) == rmax);
现在,让我们看一下相关函数:
很明显,最大值不是相关峰值的中心。 在高峰附近拟合高斯会更合适。这是子像素注册的典型方法。
让我们尝试10%的邻居:
f = fit((1:2*ceil(0.05*N)).', abs(r(x-ceil(0.05*N):x+ceil(0.05*N)-1)),'gauss1');
高斯的中心被发现为 24.94 样本,这与您的估计有些一致。你的方法似乎在某种程度上起作用,我的猜测是差异是由于信号的平滑。
修正后的曲线: