How to plot the coherence function?
21 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Andre
le 4 Juin 2013
Commenté : Csanad Levente Balogh
le 26 Nov 2020
For my two signals, x and y, I have calculated the auto- and cross-spectral density functions from the fft. So my spectral densities are Sx, Sy and Sxy.
I want to find the coherence-function, but when I just enter the formula for the coherence function directly i a get a problem with the matrix dimensions.
coh=abs(Sxy)/(Sx*Sy)
Iam sure there is a much more elegant way to do it? any suggestions? I want the unit of the frequency axis to be in rad/s.
Andre
0 commentaires
Réponse acceptée
Wayne King
le 4 Juin 2013
If you have the Signal Processing Toolbox, use mscohere()
n = 0:599;
x = cos(pi/4*n)+randn(size(n));
y = 1/2*sin(pi/4*n)+randn(size(n));
[Cxy,W] = mscohere(x,y,160,120,160);
plot(W,Cxy)
3 commentaires
Wayne King
le 4 Juin 2013
Modifié(e) : Wayne King
le 4 Juin 2013
It's in radians/sample. If you want it in radians per second, then put in the sampling frequency as an input to mscohere() and then multiple each element of the frequency vector by 2*pi
Fs = 1000;
t = 0:0.001:1-0.001;
x = cos(2*pi*100*t)+randn(size(t));
y = sin(2*pi*100*t)+randn(size(t));
[Cxy,F] = mscohere(x,y,200,150,200,Fs);
plot(F.*(2*pi),Cxy);
xlabel('Radians/Second')
Csanad Levente Balogh
le 26 Nov 2020
Hi. Dou you have a solution for if you don't have the Signal Processing Toolbox?
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Measurements and Feature Extraction dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!