Ploblem in calculating Coherence using csd funtion
2 views (last 30 days)
Show older comments
I have two time series data f1 and f2 having a period of 12hours datagap for which I wish to calculate coherence.
I have downloaded the function called func_coherence from the MATLAB Central which you have written and fed my data to it. The value coherence I am getting is 1 for all the periodicities, whereas I am seeing a strong 48h peak in Pxx, Pyy and also in Pxy.
I am attaching my data to you. to check. Please kindly help me.
F1=[ 2.4938 8.7676 2.2365 4.0216 9.2297 4.4414 1.5466 0.1564 5.9694 -2.5503 0.1252 -0.8798 4.2279 -3.4285 -5.6145 3.8539 8.3706 2.0150 -5.2399 -8.0904];
F2=[ 2.0103 3.9944 6.0057 3.3494 3.3044 6.4753 3.0004 2.1443 2.1656 0.3363 -3.1703 -1.9084 -0.5694 1.0629 -1.1216 -7.2866 3.4947 11.4590 5.0680 1.6860];
% % % Syntax [ Pxx, Pyy, Pxy, coh, pha, freq ] = func_coherence( f1, f2, nfft, Fs, filt, n_overlap )
% [Pxx,Pyy,Pxy,coh,pha,freq ] = func_coherence(F1,F2, [],1./12, [], [] );
[Pxx,freq] = csd( F1, F1, [],1./12, [], [] );
[Pyy,freq] = csd( F2, F2, [],1./12, [], [] );
[Pxy,freq] = csd( F1, F2, [],1./12, [], [] );
Kxy = real( Pxy );
Qxy = imag( Pxy );
coh = Pxy.*conj(Pxy)./(Pxx.*Pyy);
pha = mod(atan2( Qxy, Kxy ).*180/pi,360);
cix=ci(coh',95);
ts=1./freq;
Subplot(321),plot(ts,Pxx);title('P_x_x');axis tight;
Subplot(322),plot(ts,Pyy);title('P_y_y');axis tight;
Subplot(323),plot(ts,Pxy);title('P_x_y');axis tight;
Subplot(324),plot(ts,coh,ts,cix,'r');title('Coherence');axis tight;
Subplot(325),plot(ts,pha);title('Phase');axis tight;
0 Comments
Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!