How to plot the coherence function?
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Andre
am 4 Jun. 2013
Kommentiert: Csanad Levente Balogh
am 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 Kommentare
Akzeptierte Antwort
Wayne King
am 4 Jun. 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 Kommentare
Wayne King
am 4 Jun. 2013
Bearbeitet: Wayne King
am 4 Jun. 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
am 26 Nov. 2020
Hi. Dou you have a solution for if you don't have the Signal Processing Toolbox?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spectral Estimation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!