How to plot the coherence function?

24 次查看(过去 30 天)
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

采纳的回答

Wayne King
Wayne King 2013-6-4
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 个评论
Wayne King
Wayne King 2013-6-4
编辑:Wayne King 2013-6-4
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
Hi. Dou you have a solution for if you don't have the Signal Processing Toolbox?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Measurements and Feature Extraction 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by