why a component of fft to a nonzero vector is a zero(0+i0).
1 次查看(过去 30 天)
显示 更早的评论
a1=[0.0249643366619116 0.0271041369472183 0.0271041369472183 0.0242510699001427 0.0235378031383738 0.0256776034236805 0.0271041369472183 0.0285306704707561 0.0285306704707561 0.0292439372325250 0.0313837375178317 0.0328102710413695 0.0335235378031384 0.0328102710413695 0.0328102710413695 0.0335235378031384 0.0349500713266762 0.0356633380884451 0.0378031383737518 0.0399429386590585 0.0413694721825963 0.0420827389443652 0.0442225392296719 0.0470756062767475 0.0499286733238231 0.0513552068473609 0.0520684736091298 0.0556348074179743 0.0592011412268188 0.0620542082738944 0.0634807417974322 0.0649072753209700 0.0691868758915835 0.0706134094151213 0.0720399429386591 0.0727532097004280 0.0741797432239658 0.0756062767475036 0.0741797432239658 0.0734664764621969 0.0734664764621969 0.0741797432239658 0.0741797432239658 0.0727532097004280 0.0727532097004280 0.0713266761768902 0.0699001426533524 0.0670470756062768 0.0649072753209700 0.0634807417974322 0.0634807417974322 0.0627674750356633 0.0606276747503566 0.0577746077032810 0.0549215406562054 0.0527817403708987 0.0513552068473609 0.0513552068473609 0.0520684736091298 0.0520684736091298 0.0513552068473609 0.0506419400855920 0.0506419400855920 0.0513552068473609 0.0506419400855920 0.0492154065620542 0.0477888730385164 0.0463623395149786 0.0456490727532097 0.0449358059914408 0.0449358059914408 0.0442225392296719 0.0420827389443652 0.0399429386590585 0.0378031383737520 0.0370898716119829 0.0363766048502140 0.0370898716119829 0.0385164051355207 0.0399429386590585 0.0427960057061341 0.0456490727532097 0.0470756062767475 0.0463623395149786 0.0456490727532097 0.0449358059914408 0.0427960057061341 0.0406562054208274 0.0363766048502140 0.0328102710413695 0.0292439372325250 0.0256776034236805 0.0221112696148360 0.0192582025677603 0.0192582025677603 0.0185449358059914 0.0178316690442225 0.0164051355206847 0.0164051355206847 0.0164051355206847 0.0164051355206847 0.0164051355206847 0.0156918687589158 0.0199714693295292 0.0228245363766049 0.0249643366619116 0.0199714693295292 0.0164051355206847 0.0135520684736091 0.0135520684736091 0.0135520684736091 0.0149786019971469 0.0149786019971469 0.0164051355206847 0.0171184022824536 0.0178316690442225 0.0192582025677603 0.0192582025677603 0.0192582025677603 0.0171184022824536 0.0178316690442225 0.0185449358059914 0.0206847360912981 0.0178316690442225 0.0156918687589158 0.0128388017118402 0.0142653352353780 0.0149786019971469 0.0156918687589158 0.0149786019971469 0.0149786019971469 0.0149786019971469 0.0171184022824536 0.0164051355206847 0.0156918687589158 0.0149786019971469 0.0164051355206847 0.0171184022824536 0.0185449358059914 0.0178316690442225 0.0178316690442225 0.0192582025677603 0.0185449358059914 0.0206847360912981 0.0192582025677603 0.0213980028530670 0.0221112696148360 0.0249643366619116];
a2=[0.0213980028530670 0.0313837375178317 0.0235378031383738 0.0213980028530670 0.0299572039942939 0.0256776034236805 0.0263908701854494 0.0271041369472183 0.0271041369472183 0.0271041369472183 0.0320970042796006 0.0328102710413695 0.0335235378031384 0.0306704707560628 0.0306704707560628 0.0349500713266762 0.0378031383737518 0.0378031383737518 0.0449358059914408 0.0385164051355207 0.0342368045649073 0.0456490727532097 0.0413694721825963 0.0470756062767475 0.0584878744650499 0.0556348074179743 0.0534950071326676 0.0527817403708987 0.0634807417974322 0.0556348074179743 0.0599144079885877 0.0613409415121255 0.0670470756062768 0.0727532097004280 0.0677603423680457 0.0663338088445079 0.0706134094151213 0.0691868758915835 0.0734664764621969 0.0756062767475036 0.0699001426533524 0.0777460770328103 0.0720399429386591 0.0756062767475036 0.0706134094151213 0.0649072753209700 0.0649072753209700 0.0670470756062768 0.0599144079885877 0.0592011412268188 0.0620542082738944 0.0592011412268188 0.0534950071326676 0.0520684736091298 0.0492154065620542 0.0470756062767475 0.0427960057061341 0.0435092724679030 0.0470756062767475 0.0456490727532097 0.0378031383737518 0.0420827389443652 0.0463623395149786 0.0463623395149786 0.0499286733238231 0.0406562054208274 0.0435092724679030 0.0463623395149786 0.0463623395149786 0.0392296718972896 0.0385164051355207 0.0363766048502140 0.0385164051355207 0.0413694721825963 0.0356633380884451 0.0349500713266762 0.0285306704707561 0.0306704707560628 0.0385164051355207 0.0392296718972896 0.0427960057061341 0.0485021398002853 0.0477888730385164 0.0420827389443652 0.0413694721825963 0.0349500713266762 0.0406562054208274 0.0378031383737518 0.0235378031383738 0.0271041369472183 0.0299572039942939 0.0342368045649073 0.0249643366619116 0.0171184022824536 0.0149786019971469 0.0213980028530670 0.0171184022824536 0.0128388017118402 0.0135520684736091 0.0199714693295292 0.0135520684736091 0.0185449358059914 0.0192582025677603 0.0199714693295292 0.0106990014265335 0.0263908701854494 0.0221112696148360 0.0178316690442225 0.0121255349500713 0.0171184022824536 0.0192582025677603 0.0192582025677603 0.0192582025677603 0.0106990014265335 0.0135520684736091 0.0242510699001427 0.00998573466476462 0.0114122681883024 0.0156918687589158 0.0192582025677603 0.0192582025677603 0.0121255349500713 0.0206847360912981 0.0328102710413695 0.0128388017118402 0.0128388017118402 0.00427960057061341 0.00784593437945792 0.0164051355206847 0.00927246790299572 0.00713266761768902 0.00855920114122682 0.00213980028530670 0.00784593437945792 0.00570613409415121 0.00927246790299572 0.0142653352353780 0.0221112696148360 0.0106990014265335 0.00998573466476462 0.0178316690442225 0.00927246790299572 0.0349500713266762 0.0263908701854494 0.00855920114122682 0.0142653352353780 0.0442225392296719 0.0192582025677603];
These are two vectors (of length 148) I am using. I'm trying to find Phase correlation between vectors a1 and a2.
The code for phase correlation is:
x=(fft(a1).*conj(fft(a2)));
x1=real(ifft(x./abs(x)));
phase_correlation=x1(1);
I'm getting NaN output.
In fft(a1), 75 th component have zero in real part as well as in imaginary part. That is creating problem. Is there any solution for this?
I'm using Matlab(R2016a).
Thanks, in advance.
5 个评论
Temu Gautama
2020-2-13
Solution-wise, you can just add eps:
x1 = real( ifft( x ./ ( abs(x) + eps )));
I am assuming you mean phase-transform cross-correlation (phat), right? This basically tries to weight every frequency bin equally. So, if this bin is zero, it is probably safe not to take it into account (which is done by dividing zero by eps).
Temu
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!